Answer the question
In order to leave comments, you need to log in
Django 1.10 how to write an intermediate layer?
Can anyone send me an example of a middleware written in Django 1.10? Or explain how to write them?
It seems to be written simply, and even easier than in 1.9, but I don’t understand where to enter process_view(), process_exception(), process_template_response().
Answer the question
In order to leave comments, you need to log in
I need to write intermediate layers, some of which will fire before the view is selected (process_view) and some after the render (process_template_response)
def do_shit1():
pass
def do_shit2():
pass
def common_view(request):
if True:
do_shit1()
return render(request, 'tpl1.html')
else:
do_shit2()
return render(request, 'tpl2.html')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question