Recall & Review
beginner
What is middleware in Django?
Middleware is a way to process requests and responses globally before they reach the view or after the view has processed them. It acts like a chain of filters for every request and response.
Click to reveal answer
beginner
Name one built-in Django middleware that helps with security.
The SecurityMiddleware adds several security enhancements like setting security headers to protect your site from attacks.
Click to reveal answer
beginner
What does the AuthenticationMiddleware do in Django?
It associates users with requests using sessions, so you can access the current logged-in user in your views.
Click to reveal answer
intermediate
How does the CommonMiddleware help in Django?
CommonMiddleware handles tasks like URL rewriting, adding trailing slashes, and managing ETags to improve request handling.
Click to reveal answer
intermediate
Why is the CsrfViewMiddleware important in Django?
It protects your site from Cross-Site Request Forgery attacks by checking that POST requests come from trusted sources.
Click to reveal answer
Which Django middleware adds security headers to responses?
✗ Incorrect
SecurityMiddleware adds security-related headers to protect your site.
What is the main role of AuthenticationMiddleware?
✗ Incorrect
AuthenticationMiddleware links the current user to each request using sessions.
Which middleware helps prevent Cross-Site Request Forgery?
✗ Incorrect
CsrfViewMiddleware checks POST requests to ensure they come from trusted sources.
What does CommonMiddleware NOT do?
✗ Incorrect
User authentication is handled by AuthenticationMiddleware, not CommonMiddleware.
Which middleware is responsible for managing sessions in Django?
✗ Incorrect
SessionMiddleware manages session data for requests.
Explain the role of built-in middleware in Django and name three examples with their purposes.
Think about how middleware acts like filters for every request and response.
You got /4 concepts.
Describe how Django's CommonMiddleware improves request handling.
Focus on URL and header management.
You got /3 concepts.