Hello? I am trying to redirect a particular user to a custom page once they log in in django. The Admin will be directed to their usual admin interface while this particular user will go to their own custom page.
I have written this code and placed it in my views
def custLogin(request):
if request.user.username == '***':
return HttpResponseRedirect('http://********************.html')
else:
return login(request,template_name='login.html')
I have pointed the accounts/login url in urls.py to custLogin as below
(r'^accounts/login/', custLogin),
I however keep getting the error
Caught NoReverseMatch while rendering: Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found.
Any pointers please?
Maybe, you should use redirect shortcut, which returns an
HttpResponseRedirect, to point your users to different places aftercustLoginview processed.As documentation says, you can use the
redirect()function in a number of ways: by passing a view name, an object or url. See documentation for more infoNote, that I use
is_staffuser field to determine: is user an admin or not.