2
두 개의 간단한 모델이 있습니다. 책 및 저자django 1.2.1에서만 주석을/defer/only와 결합 할 수 있습니까?
각 책에는 외부 키를 통해 링크 된 한 명의 작성자가 있습니다. 작동
authors=Author.objects.all().annotate(bookcount=Count('books'))
을 : 난 단지 주석에/연기를 사용하려고 할 때까지
상황이 정상적으로 작동합니다. 쿼리는 다음과 같습니다.
select table_author.name, table_author.birthday, COUNT(table_book.id) as bookcount
from table_book left outer join table_author on table_author.id=table_book.author_id
group by table_author.id
매우 간단합니다. 작성자에서 모든 항목을 선택하고 추가적으로 책 수를 선택합니다.
하지만 다음 작업을 수행 할 때, 모든 변경 :
simple=authors.defer('birthday')
는 이제 간단한 쿼리는 다음과 같습니다
select COUNT(table_book.id) as bookcount from table_book left outer join
table_author on table_author.id=table_book.author_id group by table_author.id
과 완전히 추가 정보를 잃었다. 거래는 뭐니?
+1 장고 버그! – katrielalex