A
A
avigmati2015-06-10 13:27:47
Django
avigmati, 2015-06-10 13:27:47

Why is the variable set with the process_request middleware not showing up in a django template?

from django.core.urlresolvers import resolve
class MyCustomMiddleware(object):
# пробовал так
    def process_request(self, request):
        request.testvar = 'testval'
# пробовал и так
    def process_view(self, request, view_func, view_args, view_kwargs):
        request.testvar = 'testval'

Template {{ request.testvar }} doesn't output, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
marazmiki, 2015-06-10
@avigmati

Should be output. Is the context processor connected? Are you passing the request object to the template? Or maybe it's the inclusion tag pattern?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question