heri0n
heri0n

Reputation: 1489

Django context processors and middleware

I'm trying to set a context variable in my custom context_processor which I craft using a request variable. The request variable I'm trying to use is set in my custom middleware. However I get the following error:

AttributeError: 'WSGIRequest' object has no attribute 'my_var'

It's weird though because my context variable shows up properly. Is it because the Middleware is processed after the Context Processor? What is the correct way to do this?

Upvotes: 0

Views: 708

Answers (1)

migajek
migajek

Reputation: 8614

It depends on what method of middleware have you implemented. process_request is called before any context processor is used, however process_response is called after all the templates processing.

Upvotes: 1

Related Questions