更新これは、リリース 1.3 のバグであることが確認されています。これがチケットですhttp://code.djangoproject.com/ticket/15709
だから私はこのSQLを実装したい:
selelct id, count(*), max(insert_date) as m_d
from Book
group by id
Django ORM クエリは次のとおりです。
q = Book.objects.values('id').annotate(c = Count('id'), m_d = Max('insert_date')).order_by()
ただし、変換された sql は次のようになります。
selelct id, count(*), max(insert_date) as m_d
from Book
group by id, id <-here is another id! It messed up things!
誰でもこれに光を当てることができますか? Django 1.3 を使用しています。ありがとう!