Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6032359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:19:21+00:00 2026-05-23T05:19:21+00:00

How do I use emails instead of username for authentication using django-registration . Further

  • 0

How do I use emails instead of username for authentication using django-registration.

Further how do I enforce this change once I have already installed the registration module.

Do I edit the solution here Anyone knows a good hack to make django-registration use emails as usernames? in the lib folder?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:19:22+00:00Added an answer on May 23, 2026 at 5:19 am

    Dear fellow Django Coder,

    I think this is the best way to do it. Good luck!

    First step, is to create the form you’d like to use.

    project/accounts/forms.py

    from django import forms
    from registration.forms import RegistrationForm
    from django.contrib.auth.models import User
    
    class Email(forms.EmailField): 
        def clean(self, value):
            super(Email, self).clean(value)
            try:
                User.objects.get(email=value)
                raise forms.ValidationError("This email is already registered. Use the 'forgot password' link on the login page")
            except User.DoesNotExist:
                return value
    
    
    class UserRegistrationForm(forms.Form):
        password1 = forms.CharField(widget=forms.PasswordInput(), label="Password")
        password2 = forms.CharField(widget=forms.PasswordInput(), label="Repeat your password")
        #email will be become username
        email = Email()
    
        def clean_password(self):
            if self.data['password1'] != self.data['password2']:
                raise forms.ValidationError('Passwords are not the same')
            return self.data['password1']
    

    Here you are creating a file to override the register() function in django-registration.

    project/accounts/regbackend.py

    from django.conf import settings
    from django.contrib.sites.models import RequestSite
    from django.contrib.sites.models import Site
    
    from registration import signals
    from registration.forms import RegistrationForm
    from registration.models import RegistrationProfile
    
    from registration.backends import default
    
    
    class Backend(default.DefaultBackend):
        def register(self, request, **kwargs):
            email, password = kwargs['email'], kwargs['password1']
            username = email
            if Site._meta.installed:
                site = Site.objects.get_current()
            else:
                site = RequestSite(request)
            new_user = RegistrationProfile.objects.create_inactive_user(username, email,
                                                                        password, site)
            signals.user_registered.send(sender=self.__class__,
                                         user=new_user,
                                         request=request)
            return new_user
    

    Direct your urls to paths you want to use.

    project/urls.py

    (r'^accounts/', include('registration.backends.default.urls')),
    

    Tell your urls to use the custom backend for the registration view. Also, import the form you created and add it to the url to be processed by the view.

    project/accounts/urls.py

    from django.conf.urls.defaults import *
    from registration.backends.default.urls import *
    from accounts.forms import UserRegistrationForm
    
    urlpatterns += patterns('',
    
        #customize user registration form
        url(r'^register/$', 'registration.views.register',
            {
                'backend': 'accounts.regbackend.Backend',
                'form_class' : UserRegistrationForm
            },
            name='registration_register'
        ),
    
    ) 
    

    Hope that works!

    -Matt

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the smtp class to send emails through code. Can I use
How do i override/set authlogic to use the email field instead of the username
I found a way to customize devise to use username to login instead of
I am using the auth component but I don't want to use a username
I am looking to use quartz to schedule emails, but I'm not sure which
I'm trying to use a User model inheritance in my django application. Model looks
I already have a User table in my primary application database with an email
So in my simple learning website, I use the built in ASP.NET authentication system.
I have been wondering on how to use ASP.NET Membership together with MVC. The
I'm using a GSP for sending out emails based on the MailService plug-in. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.