-1

我正在尝试Entity从 a 中的集合中删除某个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 回答