Re: User authentication with either username or email.

2013-06-15 Thread shashank sandela
This helped alot and solved the issue. Thanks -- 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, s

Re: User authentication with either username or email.

2013-06-14 Thread Tom Evans
On Fri, Jun 14, 2013 at 3:29 PM, shashank sandela wrote: > As you can see in the views.py I did import the class > EmailOrUsernameModelBackend. OK. But you mustn't import that class, you must allow django to import it itself, and then django will use it when authenticating users. You do this by

Re: User authentication with either username or email.

2013-06-14 Thread shashank sandela
Sorry. The error was: AttributeError at /authentication/ 'User' object has no attribute 'backend' -- 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

Re: User authentication with either username or email.

2013-06-14 Thread shashank sandela
As you can see in the views.py I did import the class * EmailOrUsernameModelBackend.* * * Now when I used " *user = EmailOrUsernameModelBackend().authenticate(username=username, password=password) *" It gave an error saying: AttributeError at /tangle/auth/ 'User' object has no attribute 'backen

Re: User authentication with either username or email.

2013-06-14 Thread Enyert Viñas
El 14/06/2013 07:26 a.m., shashank sandela escribió: unbound method authenticate() must be called with EmailOrUsernameModelBackend instance as first argument (got nothing instead) Hi. Remember that you must import a function before you call it. This is a reference to authentication in Django h

Re: User authentication with either username or email.

2013-06-14 Thread Tom Evans
On Fri, Jun 14, 2013 at 12:56 PM, shashank sandela wrote: > Hi, > > I created a backends.py in my project folder. > > backends.py :: > > from django.conf import settings > from django.contrib.auth.models import User > > class EmailOrUsernameModelBackend(object): > def authenticate(self, userna

User authentication with either username or email.

2013-06-14 Thread shashank sandela
Hi, I created a backends.py in my project folder. backends.py :: *from django.conf import settings* *from django.contrib.auth.models import User* * * *class EmailOrUsernameModelBackend(object):* *def authenticate(self, username=None, password=None):* *if '@' in username:* *