0
0
Djangoframework~10 mins

Why settings configuration matters in Django - Test Your Understanding

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

Complete the code to import Django settings correctly.

Django
from django.conf import [1]
Drag options to blanks, or click blank then click option'
Asettings
Bconfig
Csetup
Denvironment
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'config' or 'setup' instead of 'settings' causes import errors.
2fill in blank
medium

Complete the code to get the DEBUG value from Django settings.

Django
debug_mode = [1].DEBUG
Drag options to blanks, or click blank then click option'
Adjango
Bconfig
Csettings
Denv
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access DEBUG from 'config' or 'env' causes attribute errors.
3fill in blank
hard

Fix the error in accessing a custom setting named MY_SETTING.

Django
my_value = [1].MY_SETTING
Drag options to blanks, or click blank then click option'
Acustom
Bconfig
Cenv
Dsettings
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'config' or 'env' instead of 'settings' leads to errors.
4fill in blank
hard

Fill both blanks to check if DEBUG is True and print a message.

Django
if [1].DEBUG [2] True:
    print('Debug mode is on')
Drag options to blanks, or click blank then click option'
Asettings
B==
C!=
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' causes the condition to be wrong.
5fill in blank
hard

Fill all three blanks to safely get a setting with a default value.

Django
value = getattr([1], '[2]', [3])
Drag options to blanks, or click blank then click option'
Asettings
BMY_SETTING
CNone
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using config instead of settings or forgetting quotes around the setting name.