Search code examples
djangopreprocessordjango-context

Django custom context processor being called twice per request


I created a simple custom context processor that needs to only be run once per request. After putting in some logging hooks I found that it is being called twice per request.

Is this a known "feature" that a missed in the docs? Is it related to the number of templates in the inheritance tree? Is it a bug in 1.03?


Solution

  • I figured out the issue. If a dictionary other than the original context is returned then the context processor seems to be executed again. Not sure why, and I can't be sure because I didn't look at the underlying code, but the after I updated the original context and returned that the issue went away. Thanks.