It does work. However the "email" field of User should be set to "blank=False" and "unique=True" if we really want to use email as the unique userid. How can we override the default field definition of User.email?
I tried something like this: from django.contrib.auth.models import User as OldUser #from django.db import models class User(OldUser): def __init__(self, *args, **kwargs): super(User, self).__init__(*args, **kwargs) #OldUser.email.blank=False #OldUser.email.unique=True class Admin: pass But the type of User.email is transferred to 'str' instead of 'CharField' so I'm stuck here. Thanks. -- John On Feb 5, 12:46 pm, "Vasily Sulatskov" <[EMAIL PROTECTED]> wrote: > Create your own authentication backend that uses emails instead of > usernames. Something like: > > from django.contrib.auth.models import User > > class BasicBackend: > def get_user(self, user_id): > try: > return User.objects.get(pk=user_id) > except User.DoesNotExist: > return None > > class EmailBackend(BasicBackend): > def authenticate(self, username=None, password=None): > try: > user = User.objects.get(email=username) > if user.check_password(password): > return user > except User.DoesNotExist: > return None > > and add to settings.py > > AUTHENTICATION_BACKENDS = ( > 'publicads.auth.EmailBackend', > ) > > Also I autogenerate usernames based on id, something like 'user_5454'. > > Works for me --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---