12.6 Intervening in Control Flow
“Don’t call us. We’ll call you.” The Hollywood principle (inversion of control) is the key to understanding how frameworks like Django operate. Sometimes, however, it becomes necessary to change core parts of Django’s behavior.
In Part I, we never had the chance to actually use the tools Django provides to inject or modify core behavior, but we’ve talked about the two major systems developers use to this end: middleware and context processors. A context processor is a function that modifies a context dictionary of a template before the template is rendered with that data. Middleware are classes that modify the HttpRequest before it arrives to the URL dispatch system and modify the HttpResponse after it is returned ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access