The serializer field might be named incorrectly and not match any attribute or key on the `User` instance.
846
投稿した質問数 58
Got AttributeError when attempting to get a value for field `title` on serializer `PostListSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `User` instance. Original exception text was: 'User' object has no attribute 'title'.
위와 같은 에러가 발생합니다.
코드를 봤는데 이유를 잘 모르겠습니다...
답변을 주신다면 너무 좋을 것 같습니다
serializers.py

views.py

urls.py

回答 1
0
안녕하세요. 독자님.
두번째 사진의 class PostListAPIView() 에서,
queryset = Post.~ 라야 하는데, queryset = User.~ 로 되어 있는게 문제 입니다.
PostListSerializer 를 만들 때 Post 테이블을 사용해야 하는데 User 테이블을 지정해서,
위와 같은 에러 메세지가 난 것입니다.
확인 바랍니다.
블로그 첫 화면이 안 나옵니다.
0
342
3
INSTALLED_APPS 순서
0
264
1
vscode 실행안됨
0
700
3
django venv activate 하고 나서 vue 서버도 실행 해야 하나요?
0
383
2
더 공부할게있을까요
0
378
1
용어에 대해 문의 드립니다.
0
285
2
like 기능을 위한 overriding 문의
0
326
1
코드 최적화 과정
0
372
1
유저 1명이 1개의 게시글에 좋아요를 누를 경우
0
363
1
프로잭트를 생성하고 runserver하면 ModuleNotFoundError: No module named 발생해요
0
900
4
GET Method 에서 왜 Like 수를 증가시키는지 궁금합니다.
0
380
1
CSRF Token에 대한 질문입니다.
0
615
1
ModuleNotFoundError: No module named 'rest_framework django' 오류
0
3047
1
앱을 구성할 때 api 앱과 blog 앱을 나누어서 구성하는 이유가 궁금합니다ㅜ
1
478
2
to_representation() 오버라이딩 질문입니다.
0
506
3
공부 순서에 관해 질문드립니다.
0
370
1
CateTagAPIView에서 get 메소드
1
314
2
깃헙 페이지를 보고싶어요
0
232
1
디버거 관련 질문입니다.
0
286
3
가장 마지막강의 (Generic View -> ViewSet migration) 질문입니다.
0
229
1
PostCommentListAPIView(게시물 댓글 조회 api) 관련 질문
0
216
1
댓글 보기 및 삭제 api
0
291
1
post, comment crud 질문
0
232
4
CateTagSerializer 질문입니다!
3
344
3

