Use email as username with django-registration -


i trying use email address username (using django 1.5's custom user model) along django-registration.

the docs version 1.0 of django-registration say:-

the base view classes deliberately user-model-agnostic. subclass them, , implement logic custom user model

i have subclassed registration view unfortunately, looks registrationprofile still expects user model have username field mine doesn't. have email (as first name, last name etc.)

is bug? looks me django-registration still needs default base user model in use - it's able use custom user model adds base model.

is there way round it? maybe can subclass registration profile well? how that?

thanks.

i think things easier in long run if keep using default user profile. if trying add ability log in email address, recommend creating new authentication backend:

from django.contrib.auth.backends import modelbackend django.contrib.auth.models import user   class emailmodelbackend(modelbackend):     def authenticate(self, username=none, password=none):         try:             user = user.objects.get(email__iexact=username)             if user.check_password(password):                 return user         except user.doesnotexist:             return none 

you need backend settings.py:

authentication_backends = (     'yourproject.yourapp.yourmodule.emailmodelbackend',     'django.contrib.auth.backends.modelbackend' ) 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -