Hi Nigel,

You could also try using django-registration . I found that it made a lot
of the things I was trying with user login/registration easier.

Vibhu



On Fri, Sep 6, 2013 at 8:05 PM, Nigel Legg <nigel.l...@gmail.com> wrote:

> I have removed the form.is_valid check and renamed the view, this now
> works (except for not directing to the correct page, it does appear to be
> logging in now)
> Thanks!
>
> Cheers, Nigel
> 07914 740972
>
>
>
> On 6 September 2013 14:35, Nigel Legg <nigel.l...@gmail.com> 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 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to