Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 31 additions & 34 deletions project_name/settings.py
Original file line number Diff line number Diff line change
@@ -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', '[email protected]'),
Expand All @@ -24,7 +22,7 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '{{ project_name }}.db',
'NAME': BASE_DIR / '{{ project_name }}.db',
'USER': '',
'PASSWORD': '',
'HOST': '',
Expand Down Expand Up @@ -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.
Expand All @@ -66,15 +64,15 @@
# 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/"
STATIC_URL = '/static/'

# 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
Expand All @@ -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',
)
Expand All @@ -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.
Expand Down Expand Up @@ -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': {
Expand Down
19 changes: 9 additions & 10 deletions project_name/urls.py
Original file line number Diff line number Diff line change
@@ -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'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing an import rapidsms.
Then it works for me.

# 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)
4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Django>=1.8,<1.9
RapidSMS==0.21.0
Django>=5.2,<5.3
RapidSMS==2.2.0