Bird
0
0

Given this production setting snippet:

medium📝 Predict Output Q4 of 15
Django - Deployment and Production
Given this production setting snippet:
DEBUG = False
ALLOWED_HOSTS = ['myapp.com']
What happens if a request comes from 'evil.com'?
ADjango will crash with an error.
BDjango will allow the request normally.
CDjango will redirect to 'myapp.com'.
DDjango will return a 400 Bad Request error.
Step-by-Step Solution
Solution:
  1. Step 1: Understand ALLOWED_HOSTS role

    ALLOWED_HOSTS lists domains Django accepts requests from when DEBUG=False.
  2. Step 2: Behavior on disallowed host

    If a request comes from a host not in ALLOWED_HOSTS, Django returns a 400 Bad Request error.
  3. Final Answer:

    Django will return a 400 Bad Request error. -> Option D
  4. Quick Check:

    Disallowed host request = 400 error [OK]
Quick Trick: Requests from unknown hosts get 400 error in production [OK]
Common Mistakes:
MISTAKES
  • Thinking Django redirects disallowed hosts
  • Assuming requests are allowed anyway

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes