문제상황
장고 유저데이터베이스의 사용성을 위해 AbstractUser모듈을 사용하기로 하여 setting.py에서 AUTH_USER_MODEL를 추가했다. 이후 makemigrations은 문제없이 수행되었으나, migrate에서 ValueError가 발생하였다.
에러 발생 이유
ValueError: The field admin.LogEntry.user was declared with a lazy reference
I'm developing a new django project and stuck with migration. I would like to make a UserModel, and in order to do that, I did two things so far. 1. I made AuthUser model and set a Meta class in the
stackoverflow.com
이 에러는 stackoverflow에서 It happens if you ran default auth app migrations and later changed the [AUTH_USER_MODEL] in [settings.py] . 즉, 기본 auth 앱 마이그레이션을 실행한 후 [settings.py]에서 [AUTH_USER_MODEL]을(를) 변경한 경우에 발생한다라고 한다.
해결방법
해결방법으로 migrations의 파일(__init__.py빼고)들과 db.sqlite3파일을 모두 삭제해준뒤, 다시 makemigrations와 migrate를 진행하면 된다고 한다
python manage.py makemigrations
python manage.py migrate
이 방법으로도 처음에는 다른 오류도 나고 했었는데 재시도하니까 성공했다!
(추가)
마냥 DB를 삭제하고 다시 만드는 것이 아무래도 영 찝찝한 마음이 들어서 구글링을 더 해봤다.
https://code.djangoproject.com/ticket/22563
#22563 (Migration of admin.LogEntry.user fails.) – Django
#22563 closed Bug (fixed) Migration of admin.LogEntry.user fails. Reported by: efrinut@… Owned by: Andrew Godwin Component: Migrations Version: 1.7-beta-2 Severity: Release blocker Keywords: Cc: stephen.r.burrows@…, k@…, loic84, Nick Polet, chtimbo@
code.djangoproject.com
settings.py에서 django.contrib.admin, urls.py에서 admin을 주석 처리 했더니 오류해결 되었다..!!!
'에러 해결 노트' 카테고리의 다른 글
Django - OSError: [Errno 22] Invalid argument \\:\\ 포함문제 (0) | 2023.08.05 |
---|---|
[GCP] 403 - Forbidden (0) | 2023.05.26 |
django error - (debug toolbar)_ django.urls.exceptions.NoReverseMatch: 'djdt' is not a registered namespace (0) | 2023.03.13 |
git error - Changes not staged for commit (0) | 2023.02.28 |