Skip to content

Commit 7902b25

Browse files
feat: Perform initial setup of django project.
1 parent f07c008 commit 7902b25

File tree

10 files changed

+157
-4
lines changed

10 files changed

+157
-4
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
max-line-length = 79
3-
# application_import_names = api
3+
application_import_names = promo_code
44
import-order-style = google
55
exclude = */migrations/, venv/, verdict.py, .venv/, env/, venv, .git, __pycache__
66
max-complexity = 10

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[settings]
22
profile = black
33
skip = migrations, venv/, venv
4-
# known_first_party = api
4+
known_first_party = promo_code
55
default_section = THIRDPARTY
66
force_sort_within_sections = true
77
line_length = 79

promo_code/manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
6+
def main():
7+
"""Run administrative tasks."""
8+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'promo_code.settings')
9+
try:
10+
from django.core.management import execute_from_command_line
11+
except ImportError as exc:
12+
raise ImportError(
13+
'Couldn`t import Django. Are you sure it`s installed and '
14+
'available on your PYTHONPATH environment variable? Did you '
15+
'forget to activate a virtual environment?',
16+
) from exc
17+
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

promo_code/promo_code/__init__.py

Whitespace-only changes.

promo_code/promo_code/asgi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
import django.core.asgi
4+
5+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'promo_code.settings')
6+
7+
application = django.core.asgi.get_asgi_application()

promo_code/promo_code/settings.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import os
2+
import pathlib
3+
4+
import django.core.exceptions
5+
import dotenv
6+
7+
8+
def load_bool(name, default):
9+
env_value = os.getenv(name, str(default)).lower()
10+
11+
return env_value in ('true', 'yes', '1', 'y', 't')
12+
13+
14+
dotenv.load_dotenv()
15+
16+
17+
BASE_DIR = pathlib.Path(__file__).resolve().parent.parent
18+
19+
20+
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
21+
if not SECRET_KEY:
22+
raise django.core.exceptions.ImproperlyConfigured(
23+
'The DJANGO_SECRET_KEY environment variable must be set!',
24+
)
25+
26+
27+
DEBUG = load_bool('DJANGO_DEBUG', False)
28+
29+
ALLOWED_HOSTS = []
30+
31+
32+
INSTALLED_APPS = [
33+
'django.contrib.admin',
34+
'django.contrib.auth',
35+
'django.contrib.contenttypes',
36+
'django.contrib.sessions',
37+
'django.contrib.messages',
38+
'django.contrib.staticfiles',
39+
]
40+
41+
MIDDLEWARE = [
42+
'django.middleware.security.SecurityMiddleware',
43+
'django.contrib.sessions.middleware.SessionMiddleware',
44+
'django.middleware.common.CommonMiddleware',
45+
'django.middleware.csrf.CsrfViewMiddleware',
46+
'django.contrib.auth.middleware.AuthenticationMiddleware',
47+
'django.contrib.messages.middleware.MessageMiddleware',
48+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
49+
]
50+
51+
ROOT_URLCONF = 'promo_code.urls'
52+
53+
TEMPLATES = [
54+
{
55+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
56+
'DIRS': [],
57+
'APP_DIRS': True,
58+
'OPTIONS': {
59+
'context_processors': [
60+
'django.template.context_processors.request',
61+
'django.contrib.auth.context_processors.auth',
62+
'django.contrib.messages.context_processors.messages',
63+
],
64+
},
65+
},
66+
]
67+
68+
WSGI_APPLICATION = 'promo_code.wsgi.application'
69+
70+
71+
DATABASES = {
72+
'default': {
73+
'ENGINE': 'django.db.backends.sqlite3',
74+
'NAME': BASE_DIR / 'db.sqlite3',
75+
},
76+
}
77+
78+
79+
AUTH_PASSWORD_VALIDATORS = [
80+
{
81+
'NAME': 'django.contrib.auth.password_validation.'
82+
'UserAttributeSimilarityValidator',
83+
},
84+
{
85+
'NAME': 'django.contrib.auth.password_validation.'
86+
'MinimumLengthValidator',
87+
},
88+
{
89+
'NAME': 'django.contrib.auth.password_validation.'
90+
'CommonPasswordValidator',
91+
},
92+
{
93+
'NAME': 'django.contrib.auth.password_validation.'
94+
'NumericPasswordValidator',
95+
},
96+
]
97+
98+
99+
LANGUAGE_CODE = 'en-us'
100+
101+
TIME_ZONE = 'UTC'
102+
103+
USE_I18N = True
104+
105+
USE_TZ = True
106+
107+
108+
STATIC_URL = 'static/'
109+
110+
111+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

promo_code/promo_code/urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import django.contrib.admin
2+
import django.urls
3+
4+
urlpatterns = [
5+
django.urls.path('admin/', django.contrib.admin.site.urls),
6+
]

promo_code/promo_code/wsgi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
import django.core.wsgi
4+
5+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'promo_code.settings')
6+
7+
application = django.core.wsgi.get_wsgi_application()

requirements/prod.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
django==5.2.*
1+
django==5.2b1
22
djangorestframework==3.15.2
33
djangorestframework-simplejwt==5.4.0
44
gunicorn==23.0.0

requirements/test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
-r flake8.txt
1+
-r flake8-plugins.txt
22
django-debug-toolbar==4.4.6

0 commit comments

Comments
 (0)