File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import os
14
14
import socket
15
+ import sys
15
16
from distutils .util import strtobool
16
17
from pathlib import Path
17
18
22
23
23
24
DEBUG = bool (strtobool (os .getenv ("DEBUG" , "false" )))
24
25
26
+ TESTING = "test" in sys .argv
27
+
25
28
# https://docs.djangoproject.com/en/5.0/ref/settings/#std:setting-ALLOWED_HOSTS
26
29
allowed_hosts = os .getenv ("ALLOWED_HOSTS" , ".localhost,127.0.0.1,[::1]" )
27
30
ALLOWED_HOSTS = list (map (str .strip , allowed_hosts .split ("," )))
28
31
29
32
# Application definitions
30
33
INSTALLED_APPS = [
31
34
"pages.apps.PagesConfig" ,
32
- "debug_toolbar" ,
33
35
"django.contrib.admin" ,
34
36
"django.contrib.auth" ,
35
37
"django.contrib.contenttypes" ,
39
41
]
40
42
41
43
MIDDLEWARE = [
42
- "debug_toolbar.middleware.DebugToolbarMiddleware" ,
43
44
"django.middleware.security.SecurityMiddleware" ,
44
45
"whitenoise.middleware.WhiteNoiseMiddleware" ,
45
46
"django.contrib.sessions.middleware.SessionMiddleware" ,
50
51
"django.middleware.clickjacking.XFrameOptionsMiddleware" ,
51
52
]
52
53
54
+ if not TESTING :
55
+ INSTALLED_APPS = [* INSTALLED_APPS , "debug_toolbar" ]
56
+ MIDDLEWARE = [
57
+ "debug_toolbar.middleware.DebugToolbarMiddleware" ,
58
+ * MIDDLEWARE ,
59
+ ]
60
+
53
61
ROOT_URLCONF = "config.urls"
54
62
55
63
# Starting with Django 4.1+ we need to pick which template loaders to use
Original file line number Diff line number Diff line change 15
15
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16
16
"""
17
17
18
+ from django .conf import settings
18
19
from django .contrib import admin
19
20
from django .urls import include
20
21
from django .urls import path
23
24
path ("up/" , include ("up.urls" )),
24
25
path ("" , include ("pages.urls" )),
25
26
path ("admin/" , admin .site .urls ),
26
- path ("__debug__/" , include ("debug_toolbar.urls" )),
27
27
]
28
+ if not settings .TESTING :
29
+ urlpatterns = [
30
+ * urlpatterns ,
31
+ path ("__debug__/" , include ("debug_toolbar.urls" )),
32
+ ]
You can’t perform that action at this time.
0 commit comments