[Fixed]-How to correctly use auto_created attribute in django?

17๐Ÿ‘

โœ…

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.

๐Ÿ‘คAlasdair

Leave a comment