0
0
Djangoframework~20 mins

DEBUG mode behavior in Django - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Django Debug Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when DEBUG is set to True in Django?

In a Django project, if you set DEBUG = True in settings.py, what is the expected behavior when an error occurs during a request?

ADjango disables all middleware and serves static files only.
BDjango shows a detailed error page with stack trace and local variables.
CDjango silently logs the error and shows a generic 500 error page to the user.
DDjango redirects the user to the homepage without any error message.
Attempts:
2 left
💡 Hint

Think about what helps developers find bugs during development.

📝 Syntax
intermediate
2:00remaining
Which setting causes Django to serve static files automatically?

In Django, when DEBUG is set to True, which of the following is true about serving static files during development?

ADjango disables static file serving when DEBUG is True.
BDjango requires manual configuration of static file serving regardless of DEBUG.
CDjango automatically serves static files using <code>django.contrib.staticfiles</code> app.
DDjango serves static files only if <code>STATIC_ROOT</code> is empty.
Attempts:
2 left
💡 Hint

Think about what makes development easier without extra setup.

🔧 Debug
advanced
2:00remaining
What error occurs if DEBUG is False but ALLOWED_HOSTS is empty?

In Django, if DEBUG = False and ALLOWED_HOSTS = [], what happens when you try to access the site?

ADjango serves the site normally without any error.
BDjango redirects all requests to the admin login page.
CDjango shows the detailed debug error page with stack trace.
DDjango raises a <code>DisallowedHost</code> exception and returns a 400 Bad Request error.
Attempts:
2 left
💡 Hint

Think about security restrictions when DEBUG is off.

state_output
advanced
2:00remaining
How does DEBUG mode affect template caching in Django?

When DEBUG is True, how does Django handle template loading compared to when DEBUG is False?

ATemplates are reloaded on every request to reflect changes immediately.
BTemplates are cached and never reloaded until the server restarts.
CTemplates are compiled to bytecode and stored permanently on disk.
DTemplates are disabled and replaced with plain HTML files.
Attempts:
2 left
💡 Hint

Think about what helps developers see changes quickly.

🧠 Conceptual
expert
2:00remaining
Why should DEBUG never be True in production?

Which of the following is the main reason to never set DEBUG = True in a production Django environment?

AIt exposes sensitive information like secret keys and database credentials in error pages.
BIt disables all middleware, causing security holes.
CIt automatically deletes user data after errors occur.
DIt prevents the server from handling HTTPS requests.
Attempts:
2 left
💡 Hint

Think about what information error pages show when debugging is on.