Home > Django > Quizzes > Django Middleware
Django Middleware
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “Enables session support. See the session documentation.”
Django Middleware
Time left 00:00
18 Questions

1. Adds the user attribute - representing the currently-logged-in user - to every incoming HttpRequest object. See Authentication in Web requests.

2. Binds commit and rollback to the request/response phase. If a view function runs successfully - a commit is done. If it fails with an exception - a rollback is done.

3. Enables session support. See the session documentation.

4. Tell the system to do something (ie. if statements)

5. To start the server

6. 1) Forbids access to user agents in the DISALLOWED_USER_AGENTS setting - which should be a list of strings. 2) Performs URL rewriting based on the APPEND_SLASH and PREPEND_WWW settings. 3) Sends broken link notification emails to MANAGERS if SEND_BRO

7. Enables language selection based on data from the request. It customizes content for each user. See the internationalization documentation.

8. Handles conditional GET operations. If the response has a ETag or Last-Modified header - and the request has If-None-Match or If-Modified-Since - the response is replaced by an HttpNotModified.

9. This method is called on each request, before Django decides which view to execute.

10. Django calls this when a view raises an exception. This should return either None or an HttpResponse object. If it returns an HttpResponse object, the response will be returned to the browser. Otherwise, default exception handling kicks in.

11. This is called just before Django calls the view. It should return either None or an HttpResponse object. If it returns None, Django will continue processing this request, executing any other such middleware and, then, the appropriate view. If it ret

12. Enable the site-wide cache. If these are enabled - each Django-powered page will be cached for as long as the CACHE_MIDDLEWARE_SECONDS setting defines. See the cache documentation.

13. This method is always called, even if the process_request() and process_view() methods of the same middleware class were skipped because an earlier middleware method returned an HttpResponse (this means that your process_response() method cannot rely

14. This must return an SimpleTemplateResponse (or its subclass) object. It could alter the given response by changing response.template_name and response.context_data, or it could create and return a brand-new SimpleTemplateResponse (or its subclass) in

15. Dictionary - Attribute - Method calls - ListIndex - It uses the first one to work using a short circuit method.

16. Enables cookie- and session-based message support.

17. Adds protection against Cross Site Request Forgeries by adding hidden form fields to POST forms and checking requests for the correct value.

18. Compresses content for browsers that understand gzip compression (all modern browsers).

⚡ Recently practiced quizzes in this topic
Live quiz activity