안녕하세요 on_delete 입력하고 서버를 구동하였는데 TypeError : on_delete must be callabel 에러표시가 나옵니다.
on_delete must be callabel 이라고 나옵니다.
휴식중인 불가사리
작성일
19.12.10 23:23
조회수
17
답변 4
문제를 해결했습니다.
django v3.0.4 사용중인데~
이와 같이 변경하니 migrate를 수행 후 웹에서 정상으로 보이지 않았던 'author' 정상적으로 나타났습니다.
답글
안녕하세요. 12월 4일자로 django 3.0 이 발표되었습니다. 그 이후에 django를 설치하셨다면 django 3.0이 설치되었을겁니다. 그 전 버전은 2.2x 버전입니다.
django 3.0에서 on_delete=true를 더 이상 지원하지 않는 것 같습니다. on_delete=models.CASCADE 로 수정하면 해당 문제는 해결됩니다만, 그 이후로도 몇가지 문제가 발생할 가능성이 있습니다.
따라서 터미널에서 pip uninstall django 하시고, pip install django==2.2 로 설치하시면 됩니다.
답글
위에서 설명한 대로 하였지만...
(venv) λ python manage.py makemigrations blog
You are trying to add a non-nullable field 'author' to post without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
2) Quit, and let me add a default in models.py
Select an option:
답글
models.py 코딩 냉용~
답글