import os try: from . import secret except ImportError: raise ImportError( "The secret.py file is missing.\n" "For a development environment, simply copy secret_example.py" ) def import_secret(name): """ Shorthand for importing a value from the secret module and raising an informative exception if a secret is missing. """ try: return getattr(secret, name) except AttributeError: raise RuntimeError("Secret missing: {}".format(name)) SECRET_KEY = import_secret("SECRET_KEY") ADMINS = import_secret("ADMINS") SERVER_EMAIL = import_secret("SERVER_EMAIL") DBNAME = import_secret("DBNAME") DBUSER = import_secret("DBUSER") DBPASSWD = import_secret("DBPASSWD") BASE_DIR = os.path.join( os.path.dirname(__file__), "..", ".." ) INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'gestion', 'partitions', 'calendrier', 'propositions', 'pads', ] 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 = "Ernestophone.urls" TEMPLATES = [{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'templates/'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', ], } }] DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", "NAME": DBNAME, "USER": DBUSER, "PASSWORD": DBPASSWD, "HOST": "localhost", } } # I18n LANGUAGE_CODE = 'fr-fr' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'media/partitions'), ) AUTH_PROFILE_MODEL = 'gestion.ErnestoUser' LOGIN_URL = "/login"