2023-04-07 TIL

0v0baek·2023년 4월 7일
0

TIL

목록 보기
24/92

[Django] makemigration시 발생하는 (fields.E304) 오류

user 하위의 models.py에서 AbstractUser를 import해서 UserModel에 상속 받아온 뒤 python manage.py runsever를 실행 해줬는데, 오류가 떴다.

SystemCheckError: System check identified some issues:

ERRORS:
auth.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'auth.User.groups' clashes with reverse accessor for 'user.UserModel.groups'.
        HINT: Add or change a related_name argument to the definition for 'auth.User.groups' or 'user.UserModel.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'auth.User.user_permissions' clashes with reverse accessor for 'user.UserModel.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'auth.User.user_permissions' or 'user.UserModel.user_permissions'.
user.UserModel.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'user.UserModel.groups' clashes 
with reverse accessor for 'auth.User.groups'.
        HINT: Add or change a related_name argument to the definition for 'user.UserModel.groups' or 'auth.User.groups'.
user.UserModel.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'user.UserModel.user_permissions' clashes with reverse accessor for 'auth.User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'user.UserModel.user_permissions' or 'auth.User.user_permissions'.

django 문서를 찾아보니 settings.pyAUTH_USER_MODEL를 추가해주지 않아서 그렇다고 한다.

추가해주자 !

# settings.py
AUTH_USER_MODEL = 'user.UserModel'

이렇게 추가시켜주면 잘 돌아간다!

profile
개발 공부 하는 비전공자 새내기. 꾸준히 합시다!

0개의 댓글