Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to allow all hosts in Django settings.
Django
ALLOWED_HOSTS = [[1]] Drag options to blanks, or click blank then click option'
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.
✗ Incorrect
Using "*" in ALLOWED_HOSTS allows Django to accept requests from any host.
2fill in blank
mediumComplete the code to allow only localhost and example.com hosts.
Django
ALLOWED_HOSTS = [[1]] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single string without commas causes a syntax error.
Using '*' allows all hosts, which is not restrictive.
✗ Incorrect
Listing hostnames as strings in ALLOWED_HOSTS restricts access to those hosts only.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a plain string without list brackets causes errors.
Using unquoted IP address is invalid syntax.
✗ Incorrect
ALLOWED_HOSTS must be a list of strings. Using ["127.0.0.1"] is correct syntax.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using IP address and hostname inconsistently.
Forgetting quotes around hostnames.
✗ Incorrect
ALLOWED_HOSTS list includes all allowed hostnames as strings.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out quotes around hostnames or IP addresses.
Using incorrect domain names not intended to be allowed.
✗ Incorrect
ALLOWED_HOSTS list should include all allowed hosts as strings in a list.