That's not my code, that's the first hit on google for my problem. I use django's own login() to login the user.
On 14 October 2013 15:07, Sergiy Khohlov <skhoh...@gmail.com> wrote: > Take a look at : > if form.is_valid(): > #django.contrib.auth.login > Login(request, form.get_user()) > str = reverse('cm_base.views.index') > return HttpResponseRedirect(str) > else: > # Their password / email combination must have been incorrect > pass > > you are verifying fields only. No more. And invalid creadentials ( > correct for form) are never go to else block > Many thanks, > > Serge > > > +380 636150445 > skype: skhohlov > > > On Mon, Oct 14, 2013 at 4:01 PM, Sergiy Khohlov <skhoh...@gmail.com> > wrote: > > I have no idea why are you writing this code by yourself ? > > This is already done ! > > Take a look at > > > https://github.com/django/django/blob/master/django/contrib/auth/views.py > > > > login function is already done and you can use it . Have no sense > > to write it by yourself. > > Many thanks, > > > > Serge > > > > > > +380 636150445 > > skype: skhohlov > > > > > > On Mon, Oct 14, 2013 at 3:52 PM, Hanne Moa <hanne....@gmail.com> wrote: > >> I can't get logging in with alternate auth backends to work with Django > 1.4 > >> or newer. > >> > >> Basically: > >> > >> 1. authenticate() works. request.user.is_authenticated() is True > >> 2. Django's own login() seems to work, as request.user is set, > >> request.session is set etc. > >> 3. After the HttpResponseRedirect, request.user is AnonymousUser > >> > >> This has happened twice now, with different alternate auth backends. I > can't > >> get rid of Django 1.3 before this is fixed... > >> > >> In one project I can call the next view directly (with render) and it > Just > >> Works. In the current project, the next view contains a form, and the > >> "login" doesn't survive the POST. > >> > >> What am I missing? See also the non-solution in > >> > http://stackoverflow.com/questions/16119155/django-request-user-not-set-after-redirect > >> > >> > >> HM > >> > >> -- > >> 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+unsubscr...@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/CACQ%3DrreSearLz5zZyu1yZWnAx_CrSOW7u0f%3DnPdVHMMOX4DOhQ%40mail.gmail.com > . > >> For more options, visit https://groups.google.com/groups/opt_out. > > -- > 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+unsubscr...@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/CADTRxJOnf8EkaR6tU5YMcKQ64GNOrHP7ShGKy2s4Wo6%3Dq1WU%3Dg%40mail.gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- 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+unsubscr...@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/CACQ%3Drre2CHhJdbX2gwObHOZkioZ-6H0vjCK-ujvBfYPjNewx3g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.