In the project do not want to use django comes with user management system, you need to add some user attributes, we can do it.
Model.py inherited AbstractUser in the app to create your own user management system like user_info
from django.contrib.auth.models import AbstractUser
class user_info(AbstractUser):
author = models.CharField(max_length=12)
login = models.BooleanField(default=False)
def __str__(self):
return self.username
After using the command python manage.py makemigrations create database tables, encountered the following error.
root@startbudd2:/home/zhj/lot/star_lot# python manage.py makemigrations
SystemCheckError: System check identified some issues:
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'user_info.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'user_info.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'user_info.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'user_info.user_permissions'.
star_link.user_info.groups: (fields.E304) Reverse accessor for 'user_info.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'user_info.groups' or 'User.groups'.
star_link.user_info.user_permissions: (fields.E304) Reverse accessor for 'user_info.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'user_info.user_permissions' or 'User.user_permissions'.
The solution to this problem:
In this project file setting.py added:
AUTH_USER_MODEL = "star_link.user_info"