카테고리 없음

[에러] UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 9735: illegal multibyte sequence

huiu 2022. 2. 15. 17:59

과거 포스트 재업로드


cmder(최신 버전)와 pycharm(최신/커뮤니티 버전)을 사용하여 실습을 진행하던 중 발견한 오류입니다.

UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 9735: illegal multibyte sequence

1. 유니코드 에러

구글링을 해보니 cp949 에러의 해결 방법은 대부분 아래와 같이 인코딩 코드를 open() 메서드에 삽입하는 방식이었습니다.

open(encoding="utf-8")
 

해결 과정이 자세하게 쓰여있는데, 제가 효과를 본 방법은

<span> 태그 내부를 (말줄임표)가 아닌 ...(마침표 3개)으로 바꿔주는 방법이었습니다.

<span>...</span>로 수정해주세요.

이외에도 다양한 해결방법이 있으니 위 링크를 꼭 참고하시는걸 추천드려요.

 

Error: no such column: blog_post.content

2. blog 앱의 post 목록이 보이지 않는 현상

다음 현상은 blog 앱의 post 모델에서 content 필드 내용을 찾지 못해 생기는 에러(?)입니다.

cmder 창에 python manage.py makemigrations 라는 명령어를 입력하면

You are trying to add a non-nullable field 'content' to post without a default; we can't do that (the database needs something to populate existing rows).
(You are trying to add a non-nullable field 'content' to post without a default; we can't do that (the database needs something to populate existing rows).)

위와 같은 경고문이 뜨는데요.

blog-migrations-models.py에 입력한 content 필드의 default 값을 null 값으로 설정해주시면 됩니다.

//content = models.TextField()에서
content = models.TextField(null=True)
 

위와 같이 수정해주세요.

이렇게 두 가지를 수정하니 정상작동했습니다.