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 558445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:07:58+00:00 2026-05-13T12:07:58+00:00

how do I change ‘username-password login’ to ’email-password login’ on django-registration

  • 0

how do I change ‘username-password login’ to ’email-password login’ on django-registration

  • 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-13T12:07:58+00:00Added an answer on May 13, 2026 at 12:07 pm

    You can’t easily store emails in django.contrib.auth.model.User‘s username field, so you’ll need a different auth backend. Put the following somewhere and add its path to AUTHENTICATION_BACKENDS. See http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend

    from django.contrib.auth.models import User
    
    class EmailBackend(object):
        """ Authenticates against the email field of django.contrib.auth.models.User
        """
    
        def authenticate(self, email=None, password=None):
            # Try using the email if it is given
            if email:
                for user in User.objects.filter(email=email):
                    if user.check_password(password):
                        return user
    
        def get_user(self, user_id):
            try:
                return User.objects.get(pk=user_id)
            except User.DoesNotExist:
                return None
    

    Then, in your views, authenticate by calling django.contrib.auth.authenticate.

    Two things to note:

    • You will probably want to keep the default AUTHENTICATION_BACKEND there, especially if you want to use the Django admin.
    • If users are signing themselves up without a username, you’ll need to create one for them. I use the base64 version of a uuid for that

    Set the username in a save method somewhere (eg in your new user form):

    import uuid, binascii
    username = binascii.b2a_base64(uuid.uuid4().bytes)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

password_change.html and htmlpassword_change_done.html are in registration folder. and, i'm using to django.contrib.auth.views.password_change and django.contrib.auth.views.password_change_done.
edit: change of question if my code is like this: <form name=login action=https://login.extremebb.net/login method=post
change all the [Titles] of a sql table without any condition I used a
Change an item in the navigation? Sure I can do that in 15 minutes.
The change target framework dialog in the portable class library properties has a link
I change hibernate.cfg.xml as the following: <!DOCTYPE hibernate-configuration PUBLIC -//Hibernate/Hibernate Configuration DTD 3.0//EN http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd>
To change the language I click on an imageButton which executes something like: SetCulture(Session,
On change of the dropdown list, A php function should called. Inside the PHP
...any change? The scenario is this: For our company we develop a standard how
This change from mootools drives me crazy. HTML <tr class=teamicon> <td style=text-align: center; width=100%

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.