You may find it easier to avoid these conflicts by doing:
from django.contrib import auth

Then use:
user = auth.authenticate(username='foo', password='bar')
auth.login(request, user)

On Jul 19, 1:02 am, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> i've been trying to get started with django and i am stock in this
> problem and found out that there's a conflict in login() method. here
> is my view code
>
> from django.http import HttpResponse, HttpResponseRedirect
> from django.shortcuts import render_to_response
> from django.contrib.auth import authenticate, login
>
> def index(request):
>     if not request.user.is_authenticated():
>         return render_to_response('login.htm', {'from':request.path})
>     return render_to_response('index.htm')
>
> def login(request):
>     if request.method == 'POST':
>         user = authenticate(username=request.POST['username'],
> password=request.POST['password'])
>         if user is not None:
>             if user.is_active:
>                 #return HttpResponse('user authenticated')
>                 fixlogin(request, user)
>                 return HttpResponseRedirect('/main/')
>             else:
>                 return HttpResponse('user not active')
>         else:
>             return HttpResponse('authenticate fail')
>     return render_to_response('login.htm')
>
> The problem is an error saying login() method accept only one
> parameter, where I follow this documentation 
> (http://www.djangoproject.com/documentation/0.96/authentication/#how-to-log-a...).
> After many times of trail and error I thought of changing this import
> from django.contrib.auth import authenticate, login to from
> django.contrib.auth import authenticate, login as fixlogin() and use
> fixlogin(request, user)
>
> Is this already fix? I am just using 0.96.
>
> Thanks
> james


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to