Differentiate context, request context in django

What is the difference between context, request context in django? Why are context processors needed?

+4
source share
1 answer

RequestContext simply goes through the TEMPLATE_CONTEXT_PROCESSORS setting and adds variables in addition to those that you explicitly pass to the context class.

Context processors are literally just a function that takes request as the first argument and returns a dictionary to add to the context.

What are they needed for? Because some very common operations, such as adding the current user to the context or STATIC_URL variables in the context, will be very repetitive, if not automatic.

+10
source

Source: https://habr.com/ru/post/1393653/


All Articles