· 4 years ago · Dec 22, 2020, 04:02 PM
1"""
2Django settings for shop_src project.
3
4Generated by 'django-admin startproject' using Django 3.1.1.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/3.1/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.1/ref/settings/
11"""
12import os
13import django_heroku
14import dj_database_url
15from pathlib import Path
16
17# Build paths inside the project like this: BASE_DIR / 'subdir'.
18BASE_DIR = Path(__file__).resolve().parent.parent
19
20
21# Quick-start development settings - unsuitable for production
22# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
23
24# SECURITY WARNING: keep the secret key used in production secret!
25SECRET_KEY = 'mxat1-teqc+xf1azm*w7r%an$&)#fbx1a#$lha&uxx!q75wy(7'
26
27# SECURITY WARNING: don't run with debug turned on in production!
28DEBUG = False
29
30ALLOWED_HOSTS = ['*']
31
32
33# Application definition
34
35INSTALLED_APPS = [
36 'django.contrib.admin',
37 'django.contrib.auth',
38 'django.contrib.contenttypes',
39 'django.contrib.sessions',
40 'django.contrib.messages',
41 'django.contrib.staticfiles',
42 'shop',
43 'crispy_forms'
44]
45
46MIDDLEWARE = [
47 'django.middleware.security.SecurityMiddleware',
48 'django.contrib.sessions.middleware.SessionMiddleware',
49 'django.middleware.common.CommonMiddleware',
50 'django.middleware.csrf.CsrfViewMiddleware',
51 'django.contrib.auth.middleware.AuthenticationMiddleware',
52 'django.contrib.messages.middleware.MessageMiddleware',
53 'django.middleware.clickjacking.XFrameOptionsMiddleware',
54]
55
56ROOT_URLCONF = 'shop_src.urls'
57
58TEMPLATES = [
59 {
60 'BACKEND': 'django.template.backends.django.DjangoTemplates',
61 'DIRS': [],
62 'APP_DIRS': True,
63 'OPTIONS': {
64 'context_processors': [
65 'django.template.context_processors.debug',
66 'django.template.context_processors.request',
67 'django.contrib.auth.context_processors.auth',
68 'django.contrib.messages.context_processors.messages',
69 ],
70 },
71 },
72]
73
74WSGI_APPLICATION = 'shop_src.wsgi.application'
75
76
77# Database
78# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
79
80DATABASES = {
81 'default': {
82 'ENGINE': 'django.db.backends.sqlite3',
83 'NAME': BASE_DIR / 'db.sqlite3',
84 }
85}
86
87
88# Password validation
89# https://docs.djangoproject.com/en/3.1/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
106LOGGING = {
107 'version': 1,
108 'disable_existing_loggers': True,
109 'handlers': {
110 'console': {
111 'class': 'logging.StreamHandler',
112 },
113 },
114 'root': {
115 'handlers': ['console'],
116 'level': 'INFO',
117 },
118}
119
120
121LANGUAGE_CODE = 'en-us'
122
123TIME_ZONE = 'UTC'
124
125USE_I18N = True
126
127USE_L10N = True
128
129USE_TZ = True
130
131
132
133
134# Static files (CSS, JavaScript, Images)
135# https://docs.djangoproject.com/en/3.1/howto/static-files/
136#das
137
138LOGIN_REDIRECT_URL = 'home'
139LOGOUT_REDIRECT_URL = 'home'
140
141STATIC_URL = '/static/'
142STATIC_ROOT = BASE_DIR / 'static'
143
144MEDIA_URL = '/media/'
145MEDIA_ROOT = BASE_DIR / "media"
146
147STATICFILES_DIRS = BASE_DIR / 'static_dev',
148
149CRISPY_TEMPLATE_PACK = 'bootstrap4'
150
151db_from_env = dj_database_url.config()
152DATABASES['default'].update(db_from_env)
153django_heroku.settings(locals())