분류 전체보기
- You are trying to add a non-nullable field '필드명' to post without a default 해결 2022.02.14
- [다잡아] 불필요한 레지스트리 왜생기는걸까? 2022.02.03
- [DRF] Image 를 create, update 하려면.. 2022.02.03
- [error!] The `.update()` method does not support writable dotted-source fields 2022.02.03
- [error!] The serializer field might be named incorrectly and not match 2022.02.03
- [Python] 장식자, 데코레이터(decorator) 를 알아보자 2022.02.02
- 스웨거란? Open API 2022.01.31
- [Django-Rest-Framwork] Postman에서 csrftoken 자동화하기 2022.01.30
- [Git] git add 취소하기, git commit 취소하기, git push 취소하기 2022.01.30
- 'IntegrityError, Not NULL constraint failed' 문제 해결하기 2022.01.29
[다잡아] 불필요한 레지스트리 왜생기는걸까?
경로를 확인해보자
글자 복붙이 안되서 캡쳐로 찍어봤음
HKUR\S-1-5-21-2690751352-4169634227-10456518-1001\Software\ (여기까지 공통)
[DRF] Image 를 create, update 하려면..
https://kimdoky.github.io/django/2018/07/12/drf-Serializerfields/
File upload fields 참고
MultiPartParser FileUploadParser 찾아보자...
https://www.django-rest-framework.org/api-guide/parsers/
https://hyun-am-coding.tistory.com/entry/7-Parsers
친절히 번역해주신 분을 찾았다. (난 영어를 못하니까)
http://daplus.net/python-django-rest-framework-%ED%8C%8C%EC%9D%BC-%EC%97%85%EB%A1%9C%EB%93%9C/
'Django > DRF' 카테고리의 다른 글
[DRF] 03. Django Rest Framework 회원 인증, 유저 모델 확장하기 (0) | 2022.01.25 |
---|---|
[DRF] 02. Django Rest Framework, Serializer, View 개념 익히기 (0) | 2022.01.24 |
[DRF] 01. Django Rest Framework 개발 환경 세팅 (0) | 2022.01.24 |
[DRF] 00. 들어가며 - Django Rest Framework로 게시판 만들기 (0) | 2022.01.24 |
postman 으로 PUT 요청을 보내면 위와 같은 에러가 뜬다.
AssertionError: The `.update()` method does not support writable dotted-source fields by default.
Write an explicit `.update()` method for serializer `apps.post.serializers.PostWriteSerializer`, or set `read_only=True` on dotted-source serializer fields.
읽기 전용 필드에서는 update() 메서드를 쓸 수 없다는 말 같다.
이거 때문에 create() 도 안됬었는데 해결 방법을 찾아보자.
'Django > error!' 카테고리의 다른 글
[error!] The serializer field might be named incorrectly and not match
AttributeError: Got AttributeError when attempting to get a value for field `thumbnail_path` on serializer `PostWirteSerializer`.
The serializer field might be named incorrectly and not match any attribute or key on the `Post` instance.
Original exception text was: 'Post' object has no attribute 'thumbnail_path'.
PostDetail 뷰로 보려고 했는데 위와 같은 에러가 떳다
Post 모델에서 thumbnail_path 컬럼을 확인해보면
thumbnail_path = serializers.CharField() 라고 되어있었는데
thumbnaill = serializers.ImageField(source="thumbnail.source" 로 고쳤더니
Post Detail 뷰가 잘 작동하는 것을 알 수 있다.
여기서 알게 된건
/api/posts/1 -> 동작o
/api/posts/1/ -> 동작o
/api/posts/2 -> 동작x
/api/posts/2/ -> 동작o
<int:1> 의 경우 끝에 /(슬래시)를 안붙여줘도 동작하는데
<int:2> 부터는 무조건 끝에 /(슬래시)가 있어야 동작한다.
'Django > error!' 카테고리의 다른 글
You are trying to add a non-nullable field '필드명' to post without a default 해결 (0) | 2022.02.14 |
---|---|
[error!] The `.update()` method does not support writable dotted-source fields (0) | 2022.02.03 |
[Django-Rest-Framwork] Postman에서 csrftoken 자동화하기 (0) | 2022.01.30 |
[Git] git add 취소하기, git commit 취소하기, git push 취소하기 (0) | 2022.01.30 |
'IntegrityError, Not NULL constraint failed' 문제 해결하기 (0) | 2022.01.29 |
[Python] 장식자, 데코레이터(decorator) 를 알아보자
스웨거란? Open API
'Django > TIL etc' 카테고리의 다른 글
[Django 패키지] isort (0) | 2022.01.21 |
---|---|
[패키지] pre-commit 도구로 Git Hook 사용하기 (0) | 2022.01.21 |
[Django 패키지] flake8 사용법 (0) | 2022.01.21 |
파이썬 패키지 관리툴 poetry 소개 (0) | 2022.01.21 |
Poetry 와 장고 프로젝트 (0) | 2022.01.21 |
[Django-Rest-Framwork] Postman에서 csrftoken 자동화하기
'Django > error!' 카테고리의 다른 글
[Git] git add 취소하기, git commit 취소하기, git push 취소하기
'Django > error!' 카테고리의 다른 글
'IntegrityError, Not NULL constraint failed' 문제 해결하기
로그인을 해야 email 필드가 채워지는데 shell 창에서 로그인을 어떻게 하는지 모르겠어서 찾아봤음...
Client 클래스를 상속 받고
위 처럼 shell 창에 작성해줄 것임
def 뭐시기를 이용하는건 아니므로 self 를 빼고 작성해줄 것임.
이런식으로 작성해주고 다시 해봤는데
(이건 테스트 코드로 테스트 해볼때 이렇게 하는듯)
author_id 를 어떻게 가져와야 되는지 모르겠음
Postman 으로 위와 같이 요청보냈는데 또 에러 발생
The `.create()` method does not support writable dotted-source fields by default.
Write an explicit `.create()` method for serializer `apps.post.serializers.PostSerializer`, or set `read_only=True` on dotted-source serializer fields.
사실 postman 상에서 로그인이 되는지 먼저 구현시키고
그다음 author, title, content, thumbnail 을 채워서 요청시켜야 되는데
지금은 로그인을 먼저 구현시키지 않은상태에서 요청을 보냈음
그래서 다시 터미널창에서 시도해볼 것임
post 컬럼에 뭐가 있는지 확인해봤는데
ForeignKey로 연결한 author 의 author_id 가 있고
OneToOne로 연결한 thumbnail 의 thumbnail_id 가 생겨있는 상태더라
참고
https://cw9206.tistory.com/105
https://blog.myungseokang.dev/posts/newbie-tests-view-in-django/
https://kimdoky.github.io/django/2018/05/01/django-shell-auth/
https://nachwon.github.io/django-9-ORM/
https://buildabetterworld.tistory.com/75