I'm trying to create a multiple user types using Django Abstract User but whenever I try to migrate the changes it gives me an error. As I'm still new to Django, I don't understand that it means
Here is my models code:
from django.db import models
from django.contrib.auth.models import AbstractUser
class CustomUser(AbstractUser):
is_customer = models.BooleanField(default = False)
is_seller = models.BooleanField(default = False)
name = models.CharField(max_length = 60)
And whenever I try to migrate this model I get this error:
ERRORS: Accounts.CustomUser.groups: (fields.E304) Reverse accessor for 'Accounts.CustomUser.groups' clashes with reverse accessor for 'auth.User.groups'. HINT: Add or change a related_name argument to the definition for 'Accounts.CustomUser.groups' or 'auth.User.groups'. Accounts.CustomUser.user_permissions: (fields.E304) Reverse accessor for 'Accounts.CustomUser.user_permissions' clashes with reverse accessor for 'auth.User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'Accounts.CustomUser.user_permissions' or 'auth.User.user_permissions'. auth.User.groups: (fields.E304) Reverse accessor for 'auth.User.groups' clashes with reverse accessor for 'Accounts.CustomUser.groups'. HINT: Add or change a related_name argument to the definition for 'auth.User.groups' or 'Accounts.CustomUser.groups'. auth.User.user_permissions: (fields.E304) Reverse accessor for 'auth.User.user_permissions' clashes with reverse accessor for 'Accounts.CustomUser.user_permissions'. HINT: Add or change a related_name argument to the definition for 'auth.User.user_permissions' or 'Accounts.CustomUser.user_permissions'.
CodePudding user response:
Add this to your settings.py
AUTH_USER_MODEL = "Accounts.CustomUser"
In General :
AUTH_USER_MODEL = "YourAppName.YourClassName"
This post is the reference.