Skip to content

Commit 4537444

Browse files
committed
Configure environment settings for debug mode
1 parent 4a5cb86 commit 4537444

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

.env.dev

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
DEBUG=1
21
SECRET_KEY=foo
32
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
43
SQL_ENGINE=django.db.backends.postgresql

docker-compose.prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
- ./.env.prod
1717
- ./email.env
1818
- ./keycloak.prod.env
19+
- ./.env.prod.host
1920
depends_on:
2021
- db
2122
db:

fabman/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212
import os
1313
from pathlib import Path
14+
from dotenv import load_dotenv
1415

1516
import _locale
1617
_locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8'])
@@ -19,20 +20,19 @@
1920
BASE_DIR = Path(__file__).resolve().parent.parent
2021

2122

22-
23+
load_dotenv('is_debug.env')
24+
DEBUG = os.environ.get('DEBUG', False) =='true'
25+
production = not DEBUG
2326

2427
# Quick-start development settings - unsuitable for production
2528
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
26-
27-
production = os.environ.get('PRODUCTION', False) == 'true'
2829
print(f'production: {production}')
2930

3031
# SECURITY WARNING: keep the secret key used in production secret!
3132
if production:
3233
SECRET_KEY = os.environ.get('SECRET_KEY')
3334
else:
3435
SECRET_KEY = 'nn@cmln2bw@@omr+_5k)!g&ylxvn+(+j@4=@1=*euv0fw3wbvi'
35-
from dotenv import load_dotenv
3636
load_dotenv('../email.env')
3737
load_dotenv('email.env')
3838
load_dotenv('keycloak.dev.env')

fabman/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
"""
1616
from django.contrib import admin
1717
from django.urls import path, include
18-
1918
from django.conf import settings
2019
from django.conf.urls.static import static
21-
2220
from fabman import views
23-
from legacy import views as legacy_views
2421

2522
urlpatterns = [
2623
path('members/', include('members.urls')),
@@ -31,11 +28,14 @@
3128
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) \
3229
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
3330

31+
if settings.DEBUG:
32+
from debug_toolbar.toolbar import debug_toolbar_urls
33+
urlpatterns += debug_toolbar_urls()
34+
3435
if not settings.DEBUG:
3536
urlpatterns.append(path('', views.index))
3637

3738

38-
from django.contrib import admin
3939
admin.site.site_header = "Fablab Sion - FabMan"
4040
admin.site.site_title = "FabMan"
4141
admin.site.index_title = ''

0 commit comments

Comments
 (0)