Brief description of the problem
In django, when creating a new User class and inheriting from the AbstractUser class, the following error occurs.
ERRORS: auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
from django.db import models
from ..db.base_model import BaseModel
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser, BaseModel):
'''User Model Class'''
class Meta:
db_table = 'df_user'
verbose_name = 'User'
verbose_name_plural = 'User'
Cause of error
This is because the new user class conflicts with Django’s own user class
Solutions
Add a line of configuration in the global setting file and use the custom model class:
AUTH_USER_MODEL = 'user.User' # where user is the app name and User is the model class name