We are social media platforms where users share his experience, stay up-to-date and grow their knowledge.
You can chat with your friends and make new friends.

Web Version 2.0.0


Login With Email Instead Of User Name In Django Admin

Login With Email Instead Of Username In Django Admin

In this tutorial, we are going to learn how to log in using email instead of the username in Django admin. It's easy, you can use it on the frontend too

let's start:

from django.db import models
from django.contrib.auth.models import AbstractUser

# Create your models here.

class User(AbstractUser):
    USERNAME_FIELD = "email"
    email = models.EmailField(max_length=255, unique=True)

Don’t forget to point AUTH_USER_MODEL to it.

AUTH_USER_MODEL = "app_name.User"

Now register the model in the app’s

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import User, UserAdmin)

You need to run the makemigrations command

python makemigrations

then have to run migrate command

python migrate

Then you have to create a superuser

python createsuperuser

For more information see Django docs


Thanks For reading
Likes by: 3 Tags: django Email-Login Authentication

Author's profile

Abdulla Fajal

Django Developer




Lives in



My name is Abdulla Fajal and I am the owner of "", if you want to give some suggestions, you can message me.


Your comment

Login Required