Basic auth struggle

20 views
Skip to first unread message

pearlball

unread,
Sep 13, 2012, 5:04:04 AM9/13/12
to django...@googlegroups.com
Struggling with my very basic django auth login system. When a new user registers, they are first redirected to `/user/user_id` as I'd like (the user is being created fine), but they are then redirected to `/login?next=/user/user_id/` which is being done by the @login_decorator over the `user` view (the behaviour stops when I remove this decorator). (nb. Debug toolbar is breaking up the redirect sequence for me to see). However, if I then manually  I include Register view below. I can't see why it is not logging in immediately upon registration. The login method seems to be all there:

    def register(request):
        if request.method == 'POST':
            form = UserCreationForm(request.POST)
            if form.is_valid():
                new_user = form.save()
                new_user = authenticate(username = request.POST['username'],
                                        password = request.POST['password1'])
                login(request, new_user)
                context = RequestContext(request)    
                context['user_id'] = new_user.id`
                url = '/user/%s/' % new_user.id
                return HttpResponseRedirect(url)
        else:
            form = UserCreationForm()
        return render_to_response("registration/register.html", {'form': form},
                                  context_instance=RequestContext(request))

Can you help? Thanks.

Timster

unread,
Sep 13, 2012, 8:06:33 AM9/13/12
to django...@googlegroups.com
What does the rest of your views.py file look like?

Do you happen to have a view named login()?

Thomas Orozco

unread,
Sep 13, 2012, 2:24:10 PM9/13/12
to django...@googlegroups.com

Could you us the line where you import login?

On Sep 13, 2012 2:06 PM, "Timster" <timsha...@gmail.com> wrote:
What does the rest of your views.py file look like?

Do you happen to have a view named login()?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ANUnnrLEVB8J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reply all
Reply to author
Forward
0 new messages