Bird
0
0

You deployed your Django app with DEBUG = False and ALLOWED_HOSTS = []. When accessing the site, you get a 400 Bad Request error. What is the likely cause?

medium📝 Debug Q14 of 15
Django - Deployment and Production
You deployed your Django app with DEBUG = False and ALLOWED_HOSTS = []. When accessing the site, you get a 400 Bad Request error. What is the likely cause?
ADEBUG must be True to allow requests
BALLOWED_HOSTS is empty, so Django blocks all hosts
CStatic files are not collected
DDatabase settings are incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Analyze ALLOWED_HOSTS effect

    An empty ALLOWED_HOSTS means no hosts are allowed, causing 400 errors.
  2. Step 2: Understand DEBUG role

    DEBUG False is correct for production; it does not cause 400 errors by itself.
  3. Final Answer:

    ALLOWED_HOSTS is empty, so Django blocks all hosts -> Option B
  4. Quick Check:

    Empty ALLOWED_HOSTS causes 400 error [OK]
Quick Trick: Empty ALLOWED_HOSTS blocks all requests [OK]
Common Mistakes:
MISTAKES
  • Thinking DEBUG True fixes 400 errors
  • Blaming static files for 400 errors
  • Assuming database issues cause 400 Bad Request

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes