这是 PyCharm 4.0.5 中的错误吗?

Is this a bug in PyCharm 4.0.5?

我昨天更新到 PyCharm 4.0.5,从那时起它一直将一些完全有效的代码标记为错误。基本上,代码只是迭代 ManyToMany 关系。代码如下所示。

songs = []
for album in order.album_products.all():
    album_songs = Song.objects.filter(album__exact=album.album_product.id)
    if not album_songs:
        for song in album_songs:
            songs.append(song)

显示错误的行是这一行:

for album in order.album_products.all():

显示的错误是:

Call 'all' directly on 'many-to-many with intermediate'. method 'all' can't be used with many-to-many relations if intermediate model is used.

我被这个难住了。从我记事起,这段代码就在 Django 中运行良好。我从 1.0 或 1.1 版开始就一直在使用 Django,并且总是使用这种方法迭代 ManyToMany 关系。同时查看 Whosebug 的答案也显示了许多其他人使用的相同代码。

有人有什么建议吗?

想知道真正的答案,因为 https://docs.djangoproject.com/en/1.7/topics/db/models/#extra-fields-on-many-to-many-relationships 显示与 beatles.members.all() 相同的代码。但在这种情况下,使用错误中提到的 intermediate model 可能会更有效。

但请注意,您对 album_products 的每个专辑执行两次查询,因为 album.album_product.id 是对

的查询
   album_songs = Song.objects.filter(album__album_product=album.album_product_id)

对我来说似乎是个错误。我不知道在哪里

method 'all' can't be used with many-to-many relations if intermediate model is used.

来自,但我没有在 Django 文档中找到它。事实上,Django 文档在 "Extra fields on many-to-many relationships":

部分的示例中使用了它
>>> beatles.members.all()

此错误在 PyCharm 中 already reported