Dans mon projet Django, j'ai une application user_manage
.
Je crée un modèle nommé UserManage
dans le fichier model.py de mon application user_manage
:
from Django.db import models
from Django.contrib.auth.models import AbstractUser
class UserManage(AbstractUser):
username = models.CharField(max_length=12)
Puis je cours:
$ python3 manage.py makemigrations
Là vient l'erreur:
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'UserManage.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'UserManage.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'UserManage.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'UserManage.user_permissions'.
users_management.UserManage.groups: (fields.E304) Reverse accessor for 'UserManage.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'UserManage.groups' or 'User.groups'.
users_management.UserManage.user_permissions: (fields.E304) Reverse accessor for 'UserManage.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'UserManage.user_permissions' or 'User.user_permissions'.
Merci pour @ABDULNIYASPM
J'ajoute le:
AUTH_USER_MODEL = "users_management.UserManage"
dans le settings.py
cela fonctionne.
Ajoutez ceci dans les paramètres:
AUTH_USER_MODEL = 'APPNAME.User'