0
0
Djangoframework~10 mins

ALLOWED_HOSTS configuration 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 allow all hosts in Django settings.

Django
ALLOWED_HOSTS = [[1]]
Drag options to blanks, or click blank then click option'
A"*"
B"localhost"
C"127.0.0.1"
D"example.com"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single hostname like 'localhost' limits access to that host only.
Leaving ALLOWED_HOSTS empty causes Django to reject all requests.
2fill in blank
medium

Complete the code to allow only localhost and example.com hosts.

Django
ALLOWED_HOSTS = [[1]]
Drag options to blanks, or click blank then click option'
A"example.org"
B"*"
C"127.0.0.1"
D"localhost", "example.com"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single string without commas causes a syntax error.
Using '*' allows all hosts, which is not restrictive.
3fill in blank
hard

Fix the error in ALLOWED_HOSTS to allow only 127.0.0.1.

Django
ALLOWED_HOSTS = [1]
Drag options to blanks, or click blank then click option'
A["127.0.0.1"]
B"127.0.0.1"
C127.0.0.1
D['127.0.0.1']
Attempts:
3 left
💡 Hint
Common Mistakes
Using a plain string without list brackets causes errors.
Using unquoted IP address is invalid syntax.
4fill in blank
hard

Fill both blanks to allow localhost and a custom domain in ALLOWED_HOSTS.

Django
ALLOWED_HOSTS = [[1], [2]]
Drag options to blanks, or click blank then click option'
A"localhost"
B"example.com"
C"127.0.0.1"
D"mydomain.org"
Attempts:
3 left
💡 Hint
Common Mistakes
Using IP address and hostname inconsistently.
Forgetting quotes around hostnames.
5fill in blank
hard

Fill all three blanks to allow localhost, 127.0.0.1, and a custom domain.

Django
ALLOWED_HOSTS = [[1], [2], [3]]
Drag options to blanks, or click blank then click option'
A"localhost"
B"127.0.0.1"
C"customdomain.com"
D"example.org"
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out quotes around hostnames or IP addresses.
Using incorrect domain names not intended to be allowed.