【发布时间】:2020-05-04 10:36:19
【问题描述】:
在测试(夹具)中,我想添加具有“通过”关系的 ManyToMany 字段的字段,即
my_field = models.ManyToManyField(SomeModel, through=AnotherModel).
尝试像常规的 ManyToManyField 一样添加:
object.my_field.add(my_field)
但它给了我这个警告信息:enter image description here
另外,试过这个:
object.my_field.add(my_field, through_defaults=AnotherModel)
也没有用
【问题讨论】:
标签: django django-models pytest fixtures pytest-django