在views.py我有:
my_computer = Computer.objects.get(pk=some_value)
计算机对象有一个名为项目的字段,它是一个ManyRelatedManager.
打电话
my_projects = my_computer.projects.all()
将值设置my_projects为三个项目对象的列表。
我想要实现的是将 的值设置my_computer.projects为上述项目列表,而不是ManyRelatedManager.
我努力了:
my_computer.projects = my_projects
但这不起作用,尽管它也不会引发错误。的值my_computer.projects仍然是ManyRelatedManager。