0
0
Djangoframework~10 mins

DEBUG mode behavior in Django - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable debug mode in Django settings.

Django
DEBUG = [1]
Drag options to blanks, or click blank then click option'
AFalse
B"True"
CNone
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string "True" instead of boolean True
Setting DEBUG to False disables debug mode
2fill in blank
medium

Complete the code to allow Django to serve static files during development when debug mode is on.

Django
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=[1])
Drag options to blanks, or click blank then click option'
Asettings.STATIC_ROOT
Bsettings.MEDIA_URL
Csettings.MEDIA_ROOT
Dsettings.STATICFILES_DIRS
Attempts:
3 left
💡 Hint
Common Mistakes
Using MEDIA_ROOT instead of STATIC_ROOT
Using MEDIA_URL which is a URL, not a path
3fill in blank
hard

Fix the error in the code to properly show detailed error pages only when debug mode is on.

Django
if [1]:
    # show detailed error page
    pass
Drag options to blanks, or click blank then click option'
Asettings.DEBUG
BDEBUG = True
CDEBUG == False
Dsettings.DEBUG == False
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment (=) instead of comparison (==)
Checking for False instead of True
4fill in blank
hard

Fill both blanks to configure Django to show detailed error pages and allow all hosts during development.

Django
DEBUG = [1]
ALLOWED_HOSTS = [[2]]
Drag options to blanks, or click blank then click option'
ATrue
B"*"
C"localhost"
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Setting DEBUG to False disables debug mode
Using 'localhost' only restricts to local host
5fill in blank
hard

Fill all three blanks to disable debug mode, set allowed hosts, and configure static files root.

Django
DEBUG = [1]
ALLOWED_HOSTS = [[2]]
STATIC_ROOT = [3]
Drag options to blanks, or click blank then click option'
ATrue
B"example.com"
CBASE_DIR / "staticfiles"
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving DEBUG as True in production
Using wildcard '*' in ALLOWED_HOSTS in production