Bird
0
0

You want to ensure your Django app is secure for production. Which combination of settings should you verify or enable after running manage.py check --deploy?

hard📝 Application Q15 of 15
Django - Security Best Practices
You want to ensure your Django app is secure for production. Which combination of settings should you verify or enable after running manage.py check --deploy?
ARemove ALLOWED_HOSTS, set DEBUG=True, and disable security middleware
BSet SECURE_SSL_REDIRECT=True, SESSION_COOKIE_SECURE=True, and DEBUG=False
CSet DEBUG=True, ALLOWED_HOSTS=['*'], and CSRF_COOKIE_SECURE=False
DKeep DEBUG=True, set SECURE_HSTS_SECONDS=0, and disable SSL redirect
Step-by-Step Solution
Solution:
  1. Step 1: Identify secure production settings

    SECURE_SSL_REDIRECT and SESSION_COOKIE_SECURE enforce HTTPS and secure cookies; DEBUG must be False in production.
  2. Step 2: Eliminate insecure options

    Options with DEBUG=True or ALLOWED_HOSTS=['*'] are insecure and should be avoided.
  3. Final Answer:

    Set SECURE_SSL_REDIRECT=True, SESSION_COOKIE_SECURE=True, and DEBUG=False -> Option B
  4. Quick Check:

    Secure settings = C [OK]
Quick Trick: Disable DEBUG and enable SSL redirect for production [OK]
Common Mistakes:
MISTAKES
  • Leaving DEBUG=True in production
  • Allowing all hosts with ALLOWED_HOSTS=['*']
  • Disabling security middleware

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes