Simple User login not working.

47 views
Skip to first unread message

Don Fox

unread,
Mar 19, 2014, 4:21:09 PM3/19/14
to django...@googlegroups.com
My project has two superusers who have access to the Django Administration and who manually add about 15 Users who should then be able to login and use the site to do data entry.

I'm using the standard code in my views


def auth_view(request):
    username = request.POST.get('username',' ')
    password = request.POST.get('password',' ')
    user = auth.authenticate(username=username, password=password)

    if user is not None:
        auth.login(request, user)
        return HttpResponseRedirect('/accounts/loggedin')
    else:
        return HttpResponseRediredt('/accounts/invalid') 


This should check against the users listed in the admin page?


        <Screen Shot 2014-03-19 at 11.32.11 AM.png>


However ther is no acknowledgement from the loggedin.hml template.


Does anything come to mind that I have newgelected to do to get the login to work.

Venkatraman S

unread,
Mar 20, 2014, 6:41:34 AM3/20/14
to django...@googlegroups.com
I cannot see the screenshot, but two things:
1. Why GET? :-/
2. Did you check if the users are 'active'? i.e, active flag set?

-Venkat


--
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...@googlegroups.com.
To post to this group, send email to django...@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/23a01c55-436b-4514-8be4-ed6a6915f879%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

C. Kirby

unread,
Mar 20, 2014, 12:11:49 PM3/20/14
to django...@googlegroups.com
If you are using stock User accounts why are you writing a login view? Just use
django.contrib.auth.views.login

You can pass it your own template in the url definition
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login' )


Reply all
Reply to author
Forward
0 new messages