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