Skip to content

Commit 5fe16c6

Browse files
committed
made changes to use python-dotenv #11
1 parent f2ce960 commit 5fe16c6

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

core/settings.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,28 @@
33
Copyright (c) 2019 - present AppSeed.us
44
"""
55

6-
import os
7-
from decouple import config
6+
import os, random, string
7+
8+
from dotenv import load_dotenv
89
from unipath import Path
910
import dj_database_url
1011

12+
load_dotenv()
13+
1114
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1215
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1316
PROJECT_DIR = Path(__file__).parent
1417

1518
# SECURITY WARNING: keep the secret key used in production secret!
16-
SECRET_KEY = config('SECRET_KEY', default='S#perS3crEt_1122')
19+
SECRET_KEY = os.environ.get('SECRET_KEY')
20+
if not SECRET_KEY:
21+
SECRET_KEY = ''.join(random.choice( string.ascii_lowercase ))
1722

1823
# SECURITY WARNING: don't run with debug turned on in production!
19-
DEBUG = config('DEBUG', default=False)
24+
DEBUG = os.getenv('DEBUG', False)
2025

2126
# load production server from .env
22-
ALLOWED_HOSTS = ['localhost', '127.0.0.1', config('SERVER', default='127.0.0.1')]
27+
ALLOWED_HOSTS = ['localhost', '127.0.0.1', os.getenv('SERVER', '127.0.0.1')]
2328

2429
# Application definition
2530

@@ -126,3 +131,11 @@
126131
)
127132
#############################################################
128133
#############################################################
134+
135+
# Default primary key field type
136+
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
137+
138+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
139+
140+
LOGIN_REDIRECT_URL = '/'
141+
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

core/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
urlpatterns = [
1010
path('admin/', admin.site.urls), # Django admin route
11-
path('admin' , admin.site.urls), # Django admin route
1211
path("", include("authentication.urls")), # Auth routes - login / register
1312
path("", include("app.urls")) # UI Kits Html files
1413
]

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
asgiref
22
autopep8
3-
django==2.2.10
3+
django
44
pycodestyle
55
pytz
66
sqlparse
77
Unipath
88
dj-database-url
9-
python-decouple
9+
python-dotenv
1010
gunicorn
1111
whitenoise
1212
django-import-export

0 commit comments

Comments
 (0)