[Django]-Django custom decorator redirect problem

4👍

Because you haven’t actually called the view function if your test succeeds.

if 'isPrivateAlfaUser' not in request.session or request.session['isPrivateAlfaUser'] != True:
    return render_to_response('homepage.html') 
else:
    return func(request, *args, **kwargs)

As a secondary note, you don’t need the outer level of wrapper here because your decorator doesn’t take any arguments. If you drop that, you also need to drop the () on the decorator itself.

0👍

you need to pass a context to render to response

return render_to_response('homepage.html', context_instance=RequestContext(request))

or render to response won’t work

Leave a comment