这是PyCharm 4.0.5中的错误吗?

Cro*_*ent 10 django pycharm python-3.x

我昨天更新到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)
Run Code Online (Sandbox Code Playgroud)

显示错误的行是这样的:

for album in order.album_products.all():
Run Code Online (Sandbox Code Playgroud)

并且显示的错误是这个:

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.
Run Code Online (Sandbox Code Playgroud)

我很难过这个.只要我记得,这段代码在Django中运行良好.我从版本1.0或1.1开始就使用Django,并且总是使用此方法迭代ManyToMany关系.另外,查看Stackoverflow答案也显示了许多其他人使用的相同代码.

有没有人有任何建议?

Jor*_*tao 15

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

如果使用中间模型,方法'all'不能与多对多关系一起使用.

是来自,但我没有在Django文档中找到它.事实上,Django docs在一个例子中使用它,在"多对多关系的额外字段"部分中:

>>> beatles.members.all()
Run Code Online (Sandbox Code Playgroud)

PyCharm中已经报告了此错误.