Skip to content

Instantly share code, notes, and snippets.

@hersonls
Last active March 15, 2022 16:11
Show Gist options
  • Save hersonls/3485035 to your computer and use it in GitHub Desktop.
Save hersonls/3485035 to your computer and use it in GitHub Desktop.
Django Settings
import os
# Project information
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
PROJECT_NAME = os.path.basename(PROJECT_PATH)
# Helpers
path = lambda *p: os.path.join(PROJECT_PATH, *p)
# Debug
DEBUG = False
TEMPLATE_DEBUG = DEBUG
# Administration
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
# Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.',
'NAME': '',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
# Site
SITE_ID = 1
# Internationalization
TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Media and Static Files
MEDIA_ROOT = path('media')
MEDIA_URL = '/m/'
STATIC_ROOT = path('static')
STATIC_URL = '/s/'
STATICFILES_DIRS = ()
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# Middlewares
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
# Templates
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
TEMPLATE_DIRS = (
path('templates'),
)
# URLs
ROOT_URLCONF = '%s.urls' % PROJECT_NAME
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = '%s.wsgi.application' % PROJECT_NAME
# Apps
INSTALLED_APPS = (
# Django Apps
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# 'django.contrib.admin',
# 'django.contrib.admindocs',
# Project Apps
# Third-party Apps
)
# Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
# Import optional settings
try:
from settings_dev import *
except ImportError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment