django Cannot set values on a ManyToManyField which specifies an intermediary model. Use Manager instead

前端 未结 5 927
长情又很酷
长情又很酷 2020-12-03 07:28

i am working on saving on the same form two tables - having a m2m relation. I don\'t succeed, my error persists with something like: Cannot set values on a ManyToManyField w

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 07:53

    If you are allowed to modify class Membership, adding auto_created = True might solve your problem,

    class Membership(models.Model): 
        class Meta:
            auto_created = True
    

    In Django 1.7, the error message is changed to "Cannot set values on a ManyToManyField which specifies an intermediary model". The solution is the same.

    NOTE: This will remove your intermediate model entirely, and all the additional fields with it.

提交回复
热议问题