I have a small project but I am trying to restrict access on some of the django app urls to login users only. The problem is that when I hit a page that requires login users I expected that they(users) are redirected to the login page however that is not the case of what happens instead they are redirected to an example url link like this '/login?next=/detail/1/' with an error message as stated "TypeError at /login/ object() takes no parameters"
-- The django project url
(r'^detail/(?P<pk>\d{1,10})/$',login_required(views.DetailViewMember.as_view)),
url(r'^login/$',views.members_login,name='login'),
The Login View Function
def members_login(request):
if request.method == 'POST':
password = request.POST['password']
username = request.POST['username']
user = authenticate(username=username,password=password)
if user is not None:
if user.is_active:
login(request,user)
return redirect('members:index') else:
#inactive users required to re-register
return redirect('members:index')#render(request,'members/login',dict(loginErr=True)) else:
#no account required to register to create one
return redirect('members:index') else:
#test if login is a regular get request then redirect
return redirect('members:index')
Can you explain to me why is it the I am getting this error?
Thank you
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9cc8283d-4fc7-4f82-bbfe-cc5d9fcfb6eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment