TIL_230925_Django 에러

Sol Lee·2023년 9월 25일
0

개인과제 - 블로그만들기(1)

오늘은 에러파티함. 개인과제 하면서 유저앱을 생성하려는데 디비랑 마이그레이션 쪽에서 계속 에러들이 남.

[ERROR] It is impossible to add a non-nullable field '필드명' to user without specifying a default. This is because the database needs something to populate existing rows.

검색해보니 새로 필드 추가하거나 수정할 때 나오는 에러고 null=Truedefault = ‘’을 넣어주면 된다고 하는데 필수값 필드로 설정해야해서 다른 방법을 찾아봄

만약 개발 초기 단계고 만들어진 데이터베이스가 중요하지 않으면 그냥 한번 삭제하고 다시 하라고 해서 migrations, db 삭제하고 다시 하니까 됨

rm 앱이름/migrations/* # migrations 삭제
rm db.sqlite3 # db 삭제
python manage.py makemigrations # 다시 마이그레이션 하기
python manage.py migrate

[stackoverflow]You are trying to add a non-nullable field 'new_field' to userprofile without a default

[ERROR] sqlite3.OperationalError: no such table: 테이블명

superuser 만드려고 하니 에러남

마이그레이션, 디비 다 삭제하고 다시 해봐도 안되서 검색해 봄

python manage.py migrate --run-syncdb 

아직 제대로 시작도 안 했는데 뭐 이리 오류가 많은지 🙃

근데 어느순간부터 마이그레이션이 인식이 안되는지 계속 바뀐게 없다고 뜸.

검색해보니 마이그레이션은 삭제 안하는게 좋다고.. ㅎㅎ…ㅎㅎㅎ…

모니터 부수고 싶지만 그냥 초기니까 공부했다 생각하고 다시 처음부터 함.

그랬더니 새로운 에러가 생김.

[ERROR] Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'

슈퍼유저 만드려고 하니 에러남

아래 링크에서 시키는대로 디비 삭제하고 다시 마이그레이션 진행했더니 쉽게 해결됨

Solution for this Error: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default

하루종일해서 유저앱 생성한 게 다라니 쉽지않네

profile
직업: 개발자가 되고 싶은 오레오 집사

0개의 댓글