You need to call authenticate() before you can call login() http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in
On Mar 26, 10:52 pm, truebosko <[EMAIL PROTECTED]> wrote: > I want to log a user in after they have registered on my site. > > Right now, I am using django-registration to handle user registration > but it is modified to not have activation. I know it doesn't really > matter what I am using as all the login is handled by > django.contrib.auth > > I've looked in the files and tried to replicate it, but all I get is > various errors. I am probably doing it horrilbly wrong. I simply want > to pass in the users new information, and then have it log them in > > I've tried doing: > login(request, new_user) after my user has registered, new_user is > the info I get from registering. > > login is referencing: from django.contrib.auth import login (I import > it right beofre that line). I've gotten the following error now: > > 'User' object has no attribute 'backend' > Request Method: POST > Request URL: http://localhost:8000/accounts/register/ > Exception Type: AttributeError > Exception Value: 'User' object has no attribute 'backend' > > Here is my registration code and where I am calling login. What is > wrong with this? > if request.method == 'POST': > form = form_class(request.POST) > if form.is_valid(): > new_user = form.save(profile_callback=profile_callback) > > from django.contrib.auth import login > login(request, new_user) > > return HttpResponseRedirect(success_url) > else: > form = form_class() > return render_to_response(template_name, > { 'form': form }, > context_instance=RequestContext(request)) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---