· 6 years ago · May 22, 2019, 06:20 AM
1"""
2Django settings for customer_tracking project.
3
4Generated by 'django-admin startproject' using Django 2.2.1.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.2/ref/settings/
11"""
12import environ
13root = environ.Path(__file__) - 3 # three folder back (/a/b/c/ - 3 = /)
14env = environ.Env(DEBUG=(bool, False),) # set default values and casting
15environ.Env.read_env() # reading .env file
16
17SITE_ROOT = root()
18
19DEBUG = env('DEBUG') # False if not in os.environ
20TEMPLATE_DEBUG = DEBUG
21# SECURITY WARNING: keep the secret key used in production secret!
22
23# SECURITY WARNING: don't run with debug turned on in production!
24
25ALLOWED_HOSTS = []
26
27
28# Application definition
29
30INSTALLED_APPS = [
31 'django.contrib.admin',
32 'django.contrib.auth',
33 'django.contrib.contenttypes',
34 'django.contrib.sessions',
35 'django.contrib.messages',
36 'django.contrib.staticfiles',
37 'rest_framework',
38 'apiCustomerTracking',
39
40]
41
42MIDDLEWARE = [
43 'django.middleware.security.SecurityMiddleware',
44 'django.contrib.sessions.middleware.SessionMiddleware',
45 'django.middleware.common.CommonMiddleware',
46 'django.middleware.csrf.CsrfViewMiddleware',
47 'django.contrib.auth.middleware.AuthenticationMiddleware',
48 'django.contrib.messages.middleware.MessageMiddleware',
49 'django.middleware.clickjacking.XFrameOptionsMiddleware',
50]
51
52ROOT_URLCONF = 'customer_tracking.urls'
53
54TEMPLATES = [
55 {
56 'BACKEND': 'django.template.backends.django.DjangoTemplates',
57 'DIRS': [('templates')]
58 ,
59 'APP_DIRS': True,
60 'OPTIONS': {
61 'context_processors': [
62 'django.template.context_processors.debug',
63 'django.template.context_processors.request',
64 'django.contrib.auth.context_processors.auth',
65 'django.contrib.messages.context_processors.messages',
66 ],
67 },
68 },
69]
70
71WSGI_APPLICATION = 'customer_tracking.wsgi.application'
72
73
74# Database
75# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
76
77DATABASES = {
78 'default': env.db(), # Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
79 'extra': env.db('SQLITE_URL', default='sqlite:////tmp/my-tmp-sqlite.db')
80}
81
82
83# Password validation
84# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
85
86AUTH_PASSWORD_VALIDATORS = [
87 {
88 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
89 },
90 {
91 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
92 },
93 {
94 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
95 },
96 {
97 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
98 },
99]
100
101
102# Internationalization
103# https://docs.djangoproject.com/en/2.2/topics/i18n/
104
105LANGUAGE_CODE = 'en-us'
106
107TIME_ZONE = 'UTC'
108
109USE_I18N = True
110
111USE_L10N = True
112
113USE_TZ = True
114
115
116# Static files (CSS, JavaScript, Images)
117# https://docs.djangoproject.com/en/2.2/howto/static-files/
118
119public_root = root.path('public/')
120
121MEDIA_ROOT = public_root('../../media')
122MEDIA_URL = '/media/'
123STATIC_ROOT = public_root('../../static')
124STATIC_URL = '/static/'
125
126SECRET_KEY = env('SECRET_KEY') # Raises ImproperlyConfigured exception if SECRET_KEY not in os.environ