Nigel..the problem with your code is..the view is getting confused with the 
view name with original django login method. So, renaming you view is a 
great idea but istead you can do this
from django.contrib.auth import login as auth_login
and call auth_login instead of login after form validation.
And always validate forms.

On Friday, September 6, 2013 7:05:09 PM UTC+5:30, Nigel Legg wrote:
>
> I am using django.contrib.auth, and have created the folowing:
>
> view:
> def login(request):
>     if request.method == 'POST':
>         form = AuthenticationForm(request.POST)
>         if form.is_valid():
>             username = request.POST['username']
>             password = request.POST['password']
>             user = authenticate(username=username, password=password)
>             if user is not None:
>                 login(request, user)
>                 if login == True:
>                     return render_to_response('myapp/list.html')
>             else:
>                 error = 'Disabled account. Pay your bill!!'
>                 return render_to_response('auth/login.html',
>                     {'form': form, 'error': error },
>                     context_instance=RequestContext(request)
>                 )
>         else:
>             error = 'invalid login...'
>             return render_to_response('auth/login.html',
>                 {'form': form, 'error': error },
>                 context_instance=RequestContext(request)
>             )
>     else:
>         form = AuthenticationForm()
>     return render_to_response(
>         'auth/login.html', {'form': form},
>         context_instance=RequestContext(request)
>     )
>
> template:
>     <body> 
>         <p> </p>
>         <!-- Start form -->
>         <form action="{% url "login" %}" method="post" 
> enctype="multipart/formdata"> {% csrf_token %}
>         <p> {{ error }} </p>
>         <p> {{ form.username.label_tag }} {{ form.username }} </p>
>         <p> {{ form.password.label_tag }} {{ form.password }} </p>
>         <p> <input type="submit" value="Login" /> </p>
>     </body>
>
> When I go to the login page, and enter the user details, it returns with 
> "invalid login", in other words it is failing the is_valid() check.  Am I 
> missing something here?  I have checked through the documentation (django 
> 1.5) and don't appear to be. 
> Any help greatly appreciated. 
>
> Cheers, Nigel 
> 07914 740972
>
>  

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to