diff --git a/project_name/settings.py b/project_name/settings.py index 2ff3a2c..ecb3b6b 100644 --- a/project_name/settings.py +++ b/project_name/settings.py @@ -1,19 +1,17 @@ # Django settings for {{ project_name }} project. - -import os +from pathlib import Path # The top directory for this project. Contains requirements/, manage.py, # and README.rst, a {{ project_name }} directory with settings etc (see # PROJECT_PATH), as well as a directory for each Django app added to this # project. -PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__)) +BASE_DIR = Path(__file__).resolve().parent.parent # The directory with this project's templates, settings, urls, static dir, # wsgi.py, fixtures, etc. -PROJECT_PATH = os.path.join(PROJECT_ROOT, '{{ project_name }}') +PROJECT_PATH = BASE_DIR / '{{ project_name }}' DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), @@ -24,7 +22,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': '{{ project_name }}.db', + 'NAME': BASE_DIR / '{{ project_name }}.db', 'USER': '', 'PASSWORD': '', 'HOST': '', @@ -55,7 +53,7 @@ # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/public/media/" -MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'public', 'media') +MEDIA_ROOT = BASE_DIR / 'public' / 'media' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. @@ -66,7 +64,7 @@ # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/public/static/" -STATIC_ROOT = os.path.join(PROJECT_ROOT, 'public', 'static') +STATIC_ROOT = BASE_DIR / 'public' / 'static' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" @@ -74,7 +72,7 @@ # Additional locations of static files to collect STATICFILES_DIRS = ( - os.path.join(PROJECT_PATH, 'static'), + PROJECT_PATH / 'static', ) # List of finder classes that know how to find static files in @@ -87,29 +85,12 @@ # Make this unique, and don't share it with anybody. SECRET_KEY = '{{ secret_key }}' -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.core.context_processors.i18n', - 'django.core.context_processors.media', - 'django.core.context_processors.static', - 'django.core.context_processors.tz', - 'django.core.context_processors.request', - 'django.contrib.messages.context_processors.messages', -) - -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', +MIDDLEWARE = ( + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) @@ -119,12 +100,28 @@ # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = '{{ project_name }}.wsgi.application' -TEMPLATE_DIRS = ( - os.path.join(PROJECT_PATH, 'templates'), -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [PROJECT_PATH / 'templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] FIXTURE_DIRS = ( - os.path.join(PROJECT_PATH, 'fixtures'), + PROJECT_PATH / 'fixtures', ) # A sample logging configuration. @@ -161,7 +158,7 @@ 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'basic', - 'filename': os.path.join(PROJECT_PATH, 'rapidsms.log'), + 'filename': PROJECT_PATH / 'rapidsms.log', }, }, 'loggers': { diff --git a/project_name/urls.py b/project_name/urls.py index 01d38be..4aae26b 100644 --- a/project_name/urls.py +++ b/project_name/urls.py @@ -1,20 +1,19 @@ from django.conf import settings -from django.conf.urls import include, url from django.conf.urls.static import static +from django.urls import include, re_path, path from django.contrib import admin - urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), + path(r'admin/', admin.site.urls), # RapidSMS core URLs - url(r'^accounts/', include('rapidsms.urls.login_logout')), - url(r'^$', 'rapidsms.views.dashboard', name='rapidsms-dashboard'), + re_path(r'^accounts/', include('rapidsms.urls.login_logout')), + re_path(r'^$', rapidsms.views.dashboard, name='rapidsms-dashboard'), # RapidSMS contrib app URLs - url(r'^httptester/', include('rapidsms.contrib.httptester.urls')), - url(r'^messagelog/', include('rapidsms.contrib.messagelog.urls')), - url(r'^messaging/', include('rapidsms.contrib.messaging.urls')), - url(r'^registration/', include('rapidsms.contrib.registration.urls')), + re_path(r'^httptester/', include('rapidsms.contrib.httptester.urls')), + re_path(r'^messagelog/', include('rapidsms.contrib.messagelog.urls')), + re_path(r'^messaging/', include('rapidsms.contrib.messaging.urls')), + re_path(r'^registration/', include('rapidsms.contrib.registration.urls')), # Third party URLs - url(r'^selectable/', include('selectable.urls')), + re_path(r'^selectable/', include('selectable.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/requirements/base.txt b/requirements/base.txt index 8c5be40..6376bfd 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,2 +1,2 @@ -Django>=1.8,<1.9 -RapidSMS==0.21.0 +Django>=5.2,<5.3 +RapidSMS==2.2.0