What are the steps to make a ModelForm work with a ManyToMany relationship with an intermediary model in Django?

前端 未结 5 1462
借酒劲吻你
借酒劲吻你 2020-12-23 11:46
  • I have a Client and Groupe Model.
  • A Client can be part of multiple groups.
  • Clients that are part of a gr
5条回答
  •  情深已故
    2020-12-23 12:34

    You probably need to remove the ManyToMany field from your Client model, or else carefully exclude it from your form. Unfortunately, the default widget for the ManyToMany field cannot populate the ClientGroupe Model properly (even if the missing field, dt, had been set to autonow=True). This is something you'll either need to break out into another form, or handle in your view.

提交回复
热议问题