は、以下を検討:関連するオブジェクトのPKMをM2M関係から取得する方法はありますか?
class Tag(Model):
...
class Post(Model):
tags = ManyToManyField(Tag) # a join table "post_tags" is created
post = Post.objects.get(pk=1)
post.tags.all() # this will cause django to join "tag" with "post_tags"
post.tags.values('pk') # even though pk is already in post_tags, django will still join with "tag" table
私の必要性が唯一のPKのリストです。誰かが、サポートされている方法、または実際の関連テーブルへの追加の参加なしで私はちょうどM2MからPKsを得ることができるきれいなハックを知っていますか?