-1

Entityのコレクションから特定のものを削除しようとしてEntityCollectionいますが、機能していないため、例外が発生します: list.remove(x): x not in list

コードの抜粋は次のとおりです。

user.platformSubscriptions.remove(platform)

プラットフォーム変数は、実際には platformSubscriptions コレクションにあります。

4

1 に答える 1

0

それが機能しなかった理由は、おそらくプラットフォームオブジェクトに適切なコンパレータ機能がなかったためです。したがって、解決策は、フィールドを比較してplatformSubscriptions一致するものを見つけるためにループすることです。platformid

for subedPlat in user.platformSubscriptions:
    if subedPlat.id == platform.user.platformSubscriptions.remove(subedPlat)
于 2011-11-18T23:39:12.710 に答える