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

前端 未结 5 921
长情又很酷
长情又很酷 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 08:14

    As seen on:

    http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany

    Unlike normal many-to-many fields, you can't use add, create, or assignment (i.e., beatles.members = [...]) to create relationships

    I guess your code trips up on the line "form.save_m2m()", which is unnecessary since you already manually create a membership.

提交回复
热议问题