How to Remove Username from Django Rest Auth Registration and login API

If you want to remove the username field from the Login/Register api endpoints then you’ll realize this is rather easy.

I’ve assumed that you’ve follow the registration instructions on the documentation so far

First create two new serializers, which will be the ones that we’ll use in the register/login endpoints. I created a file called in a folder named helper which will hold things that I’m overwriting from 3rd parties.

from dj_rest_auth.registration.serializers import RegisterSerializer
from dj_rest_auth.serializers import LoginSerializer
from rest_framework import serializers

class CustomRegisterSerializer(RegisterSerializer):
    """Use default serializer except don't user username"""

    username = None

    def get_cleaned_data(self):
        return {
            "password1": self.validated_data.get("password1", ""),
            "email": self.validated_data.get("email", ""),

class CustomLoginSerializer(LoginSerializer):
    """Use default serializer except don't user username"""

    username = None

Second step is tell django to use these new serializers and to forget about using the username field for anything. Go to file and add these

### Django AllAuth settings
# Telling Allauth that we will NOT use username
# Don't require username
# Still require email
# Login with email (default is username)

### Django Rest Auth settings


I recommend you read up on the configuration documentation for both Django Rest Auth and Django AllAuth

After this you should be able to register and login without being prompted for username :)

Note: You’ll encounter an error when you register and try to do the email confirmation. That is a topic for another blog post and the result for changing up the defaults.