0

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
heri0n
  • 1,459
  • 3
  • 19
  • 33

1 Answers1

1

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.

migajek
  • 8,524
  • 15
  • 77
  • 116