Django Writing Custom Context Processor
Solution 1:
Instead of
'auth.context_processors.auth0_processors'
give the concrete method:
'auth.context_processors.auth0_processors.auth0_user'
At least that is what the error is complaining about:
does not define a "auth0_processors" attribute/class
It is looking for a class or attribute, so try with the function name.
From the documentation:
The context_processors option is a list of callables – called context processors – that take a request object as their argument and return a dictionary of items to be merged into the context.
In answer to your comment:
If you always need the same objects then just create one method that adds all of the required objects to the context instead of several methods.
EDIT:
Also note that with 'django.template.context_processors.request'
you could already have the complete request
object in the context. You might not need your own context processor if you just need access to the session.
Post a Comment for "Django Writing Custom Context Processor"