· 6 years ago · Oct 21, 2019, 08:58 AM
1"""
2Django settings for composeexample project.
3
4Generated by 'django-admin startproject' using Django 1.11.5.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/1.11/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.11/ref/settings/
11"""
12
13import os
14import environ
15
16env = environ.Env(
17 # set casting, default value
18 DEBUG=(bool, False)
19)
20# reading .env file
21environ.Env.read_env()
22
23# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
24BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
25
26
27# Quick-start development settings - unsuitable for production
28# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
29
30# SECURITY WARNING: keep the secret key used in production secret!
31# Raises django's ImproperlyConfigured exception if SECRET_KEY not in os.environ
32SECRET_KEY = env('SECRET_KEY')
33
34
35# SECURITY WARNING: don't run with debug turned on in production!
36DEBUG = env('DEBUG')
37
38ALLOWED_HOSTS = ['localhost']
39
40# Application definition
41
42INSTALLED_APPS = [
43 'app',
44 'django.contrib.admin',
45 'django.contrib.auth',
46 'django.contrib.contenttypes',
47 'django.contrib.sessions',
48 'django.contrib.messages',
49 'django.contrib.staticfiles',
50]
51
52MIDDLEWARE = [
53 'django.middleware.security.SecurityMiddleware',
54 'django.contrib.sessions.middleware.SessionMiddleware',
55 'django.middleware.common.CommonMiddleware',
56 'django.middleware.csrf.CsrfViewMiddleware',
57 'django.contrib.auth.middleware.AuthenticationMiddleware',
58 'django.contrib.messages.middleware.MessageMiddleware',
59 'django.middleware.clickjacking.XFrameOptionsMiddleware',
60]
61
62
63ROOT_URLCONF = 'composeexample.urls'
64
65TEMPLATES = [
66 {
67 'BACKEND': 'django.template.backends.django.DjangoTemplates',
68 'DIRS': [],
69 'APP_DIRS': True,
70 'OPTIONS': {
71 'context_processors': [
72 'django.template.context_processors.debug',
73 'django.template.context_processors.request',
74 'django.contrib.auth.context_processors.auth',
75 'django.contrib.messages.context_processors.messages',
76 ],
77 },
78 },
79]
80
81WSGI_APPLICATION = 'composeexample.wsgi.application'
82
83
84# Database
85# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
86
87# Parse database connection url strings like psql://user:pass@127.0.0.1:8458/db
88DATABASES = {
89 # read os.environ['DATABASE_URL'] and raises ImproperlyConfigured exception if not found
90 'default': env.db(),
91}
92
93# Password validation
94# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
95
96AUTH_PASSWORD_VALIDATORS = [
97 {
98 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
99 },
100 {
101 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
102 'OPTIONS': {
103 'min_length': 9,
104 }
105 },
106 {
107 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
108 },
109 {
110 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
111 },
112]
113
114
115# Internationalization
116# https://docs.djangoproject.com/en/1.11/topics/i18n/
117
118LANGUAGE_CODE = 'en-us'
119
120TIME_ZONE = 'UTC'
121
122USE_I18N = True
123
124USE_L10N = True
125
126USE_TZ = True
127
128
129# Static files (CSS, JavaScript, Images)
130# https://docs.djangoproject.com/en/1.11/howto/static-files/
131
132STATIC_URL = '/static/'
133
134STATICFILES_DIRS = [
135 os.path.join(BASE_DIR, "static"),
136 '/var/www/static/',
137]