Browse Source

Settings quebrado em multiplos arquivos

producao
Marcio Mazza 10 years ago
parent
commit
aac67d043e
  1. 2
      .gitignore
  2. 7
      sigi/settings/__init__.py
  3. 41
      sigi/settings/base.py
  4. 26
      sigi/settings/dev.py

2
.gitignore

@ -45,4 +45,4 @@ static
.pydevproject
.vagrant
sigi/local_settings.py
sigi/settings/prod.py

7
sigi/settings/__init__.py

@ -0,0 +1,7 @@
try:
from prod import *
except ImportError:
from warnings import warn
msg = "You don't have a production settings file, using development settings."
warn(msg, category=ImportWarning)
from dev import *

41
sigi/settings.py → sigi/settings/base.py

@ -10,19 +10,16 @@ https://docs.djangoproject.com/en/dev/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from os.path import dirname
import django.conf.global_settings as DEFAULT_SETTINGS
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
BASE_DIR = dirname(dirname(dirname(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0$ip1fb5xtq%a=)-k_4r^(#jn0t^@+*^kihkxkozg-mip7+w3+'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = []
ADMINS = (
@ -39,8 +36,7 @@ TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
# 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',
)
)
# Application definition
INSTALLED_APPS = (
@ -85,16 +81,6 @@ MIDDLEWARE_CLASSES = (
ROOT_URLCONF = 'sigi.urls'
WSGI_APPLICATION = 'sigi.wsgi.application'
# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'sigi.db'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/dev/topics/i18n/
LANGUAGE_CODE = 'pt-br'
@ -121,20 +107,3 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
try:
from local_settings import *
except ImportError:
from warnings import warn
msg = "You don't have local_settings.py file, using defaults settings."
try:
# don't work in Python 2.4 or before
warn(msg, category=ImportWarning)
except NameError:
warn(msg)

26
sigi/settings/dev.py

@ -0,0 +1,26 @@
from base import *
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0$ip1fb5xtq%a=)-k_4r^(#jn0t^@+*^kihkxkozg-mip7+w3+'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'sigi.db'),
}
}
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = DEBUG
INSTALLED_APPS += (
'debug_toolbar',
)
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
Loading…
Cancel
Save