1
나는이 작품 이유를 알아 내려고 노력 해요 :댓글과 content_object
이>>> comments = Comment.objects.all()
>>>[c.content_object for c in comments]
를 [코멘트가 부착 된 개체의 목록을 반환]하지만이되지 않습니다 :
을>>> c = Comment.objects.filter(id=111)
>>> c
[<Comment: Related object name here ...>]
>>> c.content_object
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'QuerySet' object has no attribute 'content_object'
두 경우 모두 각 "c"는 설명 인스턴스입니다. 그렇다면 왜 첫 번째 경우에는 c가 content_object 속성을 갖지만 두 번째 경우에는 그렇지 않습니다. 감사.
정확히 올바른 다니엘. 내가 그것을 어떻게 놓쳤는지 명확히하지 않고있다 (그것은 늦었다 :). 그러나 고마워. – shacker