I need to create my own intermediate model.
class class1(models.Model):
pass
class class2(models.Model):
field1 = models.ManyToManyField(class1, through=
As far as I am aware, the auto_created
attribute in the Meta
class is undocumented, so you should avoid using it.
As the AttributeError
says, it is not possible to use add()
for a many to many field that uses an intermediary model. The correct fix is to create an instance of the intermediate model, instead of using add()
.
class3.objects.create(field_1=c1, field_2=c2, field_3=1).
See the docs on extra fields in many to many relationships for more info.