django middleware redirect doesn't render page
I am writing custom middlware that I want to redirect to another page if a
condition is met. My code looks like this:
class SettingHandler(object):
def process_view(self, request, view_func, view_args, view_kwargs):
if request.setting:
return view_func(request, *view_args, **view_kwargs)
else:
return HttpResponseRedirect(reverse('setting'))
When the redirect condition is reached, the page doesn't render. The
output in the console looks like this:
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
How can I redirect to the desired page?
No comments:
Post a Comment