Skip to content

Commit 78fa6c5

Browse files
author
PRITAM CHAKRABORTY
committed
prod semi ready
1 parent 27e0d21 commit 78fa6c5

File tree

10 files changed

+51
-36
lines changed

10 files changed

+51
-36
lines changed

core/asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
from django.core.asgi import get_asgi_application
1313

14-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings.dev')
1515

1616
application = get_asgi_application()

core/settings/common.py

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,15 @@
1212

1313
from datetime import timedelta
1414
from pathlib import Path
15+
import os
1516

1617
# Build paths inside the project like this: BASE_DIR / 'subdir'.
17-
BASE_DIR = Path(__file__).resolve().parent.parent
18+
BASE_DIR = Path(__file__).resolve().parent.parent.parent
1819

1920

2021
# Quick-start development settings - unsuitable for production
2122
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
2223

23-
# SECURITY WARNING: keep the secret key used in production secret!
24-
SECRET_KEY = 'django-insecure-d0h()gl&k^-$xw8l7aurj0_q!(7byex0n(j=03xfsyn7jqyn+-'
25-
26-
# SECURITY WARNING: don't run with debug turned on in production!
27-
DEBUG = True
28-
29-
ALLOWED_HOSTS = []
30-
31-
3224
# Application definition
3325

3426
INSTALLED_APPS = [
@@ -39,6 +31,7 @@
3931
'django.contrib.messages',
4032
'django.contrib.staticfiles',
4133
# 3rd party apps
34+
"debug_toolbar",
4235
'rest_framework',
4336
'djoser',
4437
'django_extensions',
@@ -61,15 +54,9 @@
6154
'django.contrib.messages.middleware.MessageMiddleware',
6255
'django.middleware.clickjacking.XFrameOptionsMiddleware',
6356
# 3rd party middleware
64-
# "debug_toolbar.middleware.DebugToolbarMiddleware",
57+
"debug_toolbar.middleware.DebugToolbarMiddleware",
6558
]
6659

67-
if DEBUG:
68-
INTERNAL_IPS = [
69-
"127.0.0.1",
70-
]
71-
INSTALLED_APPS += ["debug_toolbar"]
72-
MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
7360

7461
ROOT_URLCONF = 'core.urls'
7562

@@ -92,17 +79,6 @@
9279
WSGI_APPLICATION = 'core.wsgi.application'
9380

9481

95-
# Database
96-
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
97-
98-
DATABASES = {
99-
'default': {
100-
'ENGINE': 'django.db.backends.sqlite3',
101-
'NAME': BASE_DIR / 'db.sqlite3',
102-
}
103-
}
104-
105-
10682
# Password validation
10783
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
10884

@@ -133,12 +109,15 @@
133109

134110
USE_TZ = True
135111

112+
INTERNAL_IPS = [
113+
"127.0.0.1",
114+
]
136115

137116
# Static files (CSS, JavaScript, Images)
138117
# https://docs.djangoproject.com/en/4.0/howto/static-files/
139118

140119
STATIC_URL = 'static/'
141-
STATIC_ROOT = BASE_DIR / 'static'
120+
STATIC_ROOT = os.path.join(BASE_DIR ,'static')
142121

143122

144123
# Default primary key field type

core/settings/dev.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
from .common import *
1+
from .common import *
2+
3+
# SECURITY WARNING: keep the secret key used in production secret!
4+
SECRET_KEY = 'django-insecure-d0h()gl&k^-$xw8l7aurj0_q!(7byex0n(j=03xfsyn7jqyn+-'
5+
6+
DEBUG = True
7+
8+
9+
# if DEBUG == True:
10+
# INSTALLED_APPS += ["debug_toolbar"]
11+
# MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
12+
13+
14+
# Database
15+
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
16+
17+
DATABASES = {
18+
'default': {
19+
'ENGINE': 'django.db.backends.sqlite3',
20+
'NAME': BASE_DIR / 'db.sqlite3',
21+
}
22+
}

core/settings/prod.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
from .common import *
1+
from os import environ, path
2+
from .common import *
3+
4+
SECRET_KEY = environ.get('SECRET_KEY')
5+
6+
DEBUG = False
7+
8+
ALLOWED_HOSTS = []

core/urls.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,21 @@
1313
1. Import the include() function: from django.urls import include, path
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
16+
from django.conf import settings ,urls
1617
from django.contrib import admin
1718
from django.urls import path, include
19+
from django.conf.urls.static import static
1820

1921
urlpatterns = [
2022
path('admin/', admin.site.urls),
2123
path('auth/', include('djoser.urls')),
2224
path('auth/', include('djoser.urls.jwt')),
2325
# path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
24-
# path("__debug__/", include("debug_toolbar.urls")),
2526
# own app routes
2627
path('blogapp/', include("blogapp.urls")),
2728
]
29+
# urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
30+
31+
if settings.DEBUG:
32+
import debug_toolbar
33+
urlpatterns+=path("__debug__/", include(debug_toolbar.urls)),

core/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
from django.core.wsgi import get_wsgi_application
1313

14-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings.dev')
1515

1616
application = get_wsgi_application()

db.sqlite3

0 Bytes
Binary file not shown.

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def main():
88
"""Run administrative tasks."""
9-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings.dev')
1010
try:
1111
from django.core.management import execute_from_command_line
1212
except ImportError as exc:

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
export DJANGO_SETTINGS_MODULE = core.settings
2+
export DJANGO_SETTINGS_MODULE = core.settings.dev

tokens/user@4.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"refresh": eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY0NjI5NTYxOSwianRpIjoiMWMzZjA0MzYwYTQzNDAzMGE1OGEyZWQxYjFmMThlZTIiLCJ1c2VyX2lkIjoxfQ.dK9BxYxPZtR6iclk2jTF8bvnlxuBT9gOYMJQc9Ui2Z8
2+
"access": eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjQ2ODE0NDAwLCJqdGkiOiIxNmI2NjYxOGFkYTI0ZWI4YjI5Y2I0ZTE4NzZmOWFhMCIsInVzZXJfaWQiOjE5fQ.me0O0oBLg6Yo8G-FQF-fO9KKdncdjRlksfN5LXQYGY0

0 commit comments

Comments
 (0)