emaildjango-rest-frameworkdjango-allauthdjango-custom-userdj-rest-auth

django-allauth W001: ACCOUNT_LOGIN_METHODS conflicts with ACCOUNT_SIGNUP_FIELDS with Custom User Model (email as USERNAME_FIELD)


I'm working on a Django project using django-allauth and dj-rest-auth for authentication. I've set up a custom user model (CustomUser) where email is the USERNAME_FIELD and username is set to None. I'm consistently getting the following warning during system checks:

?: (account.W001) ACCOUNT_LOGIN_METHODS conflicts with ACCOUNT_SIGNUP_FIELDS 

Despite trying various configurations for ACCOUNT_LOGIN_METHODS and ACCOUNT_SIGNUP_FIELDS in my settings.py, this warning persists. My application seems to work (login/registration via email), but I'd like to resolve this warning to ensure my configuration is correct. Here are the relevant parts of my setup: models.py (users app):

from django.contrib.auth.models import AbstractUser 
from django.db import models
from .managers import CustomUserManager
class CustomUser(AbstractUser):
    username = None 
    email = models.EmailField(unique=True)

    is_active = models.BooleanField(default=True)
    is_staff = models.BooleanField(default=False)
    is_superuser = models.BooleanField(default=False)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = []
    objects = CustomUserManager()

    def __str__(self):
        return self.email

settings.py (relevant allauth/dj-rest-auth parts):


REST_FRAMEWORK = {

    'DEFAULT_AUTHENTICATION_CLASSES':(
        'rest_framework_simplejwt.authentication.JWTAuthentication',
        'dj_rest_auth.jwt_auth.JWTCookieAuthentication',
    )
}

# dj-rest-auth

# authentication Backend

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
]


ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_LOGIN_METHODS = {'email'}

ACCOUNT_SIGNUP_FIELDS = ['email','password']

ACCOUNT_EMAIL_VERIFICATION = 'none'

serializers.py:

from rest_framework import serializers
from .models import CustomUser


class RegisterSerializer(serializers.ModelSerializer):
    password = serializers.CharField(write_only=True)
    password2 = serializers.CharField(write_only=True, label="Confirm Password")

    class Meta:
        model = CustomUser
        fields = ['email', 'first_name', 'last_name','password', 'password2']

    def validate(self, attrs):
        if attrs['password'] != attrs['password2']:
            raise serializers.ValidationError({"password": "Your passwords didn't match."})
        return attrs
    
    def create(self, validated_data):
        validated_data.pop('password2')
        user = CustomUser.objects.create_user(**validated_data)
        return user 

Full Warning Output :

/home/roni/Desktop/FitCore/env/lib/python3.12/site-packages/dj_rest_auth/registration/serializers.py:228: UserWarning: app_settings.USERNAME_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['username']['required']
  required=allauth_account_settings.USERNAME_REQUIRED,
/home/roni/Desktop/FitCore/env/lib/python3.12/site-packages/dj_rest_auth/registration/serializers.py:230: UserWarning: app_settings.EMAIL_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['email']['required']
  email = serializers.EmailField(required=allauth_account_settings.EMAIL_REQUIRED)
/home/roni/Desktop/FitCore/env/lib/python3.12/site-packages/dj_rest_auth/registration/serializers.py:288: UserWarning: app_settings.EMAIL_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['email']['required']
  email = serializers.EmailField(required=allauth_account_settings.EMAIL_REQUIRED)
System check identified some issues:

WARNINGS:
?: (account.W001) ACCOUNT_LOGIN_METHODS conflicts with ACCOUNT_SIGNUP_FIELDS

System check identified 1 issue (0 silenced).
May 28, 2025 - 16:33:56
Django version 5.2.1, using settings 'fitcore.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Django: 5.2.1 Python: 3.12.x django-allauth: 65.8.1 dj-rest-auth: 7.0.1 What I've tried specifically for the W001 warning: ACCOUNT_SIGNUP_FIELDS = ['email'] ACCOUNT_SIGNUP_FIELDS = ['email', 'password'] Ensured ACCOUNT_USER_MODEL_USERNAME_FIELD = None and ACCOUNT_LOGIN_METHODS = ('email',) are set. Ensured deprecated allauth settings are removed.

My Questions:

  1. Why am I still getting the W001 warning despite these configurations?
  2. What is the definitive correct configuration for ACCOUNT_LOGIN_METHODS and ACCOUNT_SIGNUP_FIELDS when using email as the primary identifier (USERNAME_FIELD='email') and username = None?
  3. Could my RegisterSerializer (used by dj-rest-auth) be somehow influencing allauth's interpretation of these settings, leading to the conflict?

Any insights or suggestions would be greatly appreciated!


Solution

  • Your signup fields has email as optional, Make it required by using "email*":

    ACCOUNT_SIGNUP_FIELDS = ["email*", "password*"]
    

    See this similar issue and the docs.