Skip to content

Instantly share code, notes, and snippets.

@iainmcampbell
Last active August 29, 2015 14:11
Show Gist options
  • Save iainmcampbell/778f67996b878a73f936 to your computer and use it in GitHub Desktop.
Save iainmcampbell/778f67996b878a73f936 to your computer and use it in GitHub Desktop.
Django Settings Stem
"""
Django settings for <project> project.
With Grappelli.
https://docs.djangoproject.com/en/1.7/topics/settings/
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ''
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'grappelli',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
)
MIDDLEWARE_CLASSES = (
'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',
)
ROOT_URLCONF = '<project>.urls'
WSGI_APPLICATION = '<project>.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Grappelli
# http://django-grappelli.readthedocs.org/en/latest/
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
"django.core.context_processors.request",
'django.core.context_processors.media',
)
GRAPPELLI_ADMIN_TITLE = 'Shoebox Archive Project'
# User Roles
# https://github.com/dabapps/django-user-roles
USER_ROLES = ( 'admin', 'editor', 'contributor', )
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Template files
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader'
)
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, ''),
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
from django.conf.urls import patterns, include, url
from django.contrib import admin
from <app> import views
# for serving static files using the dev server
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = patterns('',
# Examples:
# url(r'^blog/', include('blog.urls')),
# url(r'^$', '<app>.views.<view>', name=''),
url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS
url(r'^admin/', include(admin.site.urls)), # admin site
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# https://docs.djangoproject.com/en/1.7/howto/static-files/#serving-static-files-during-development
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment