Your intermediate model must contain one - and only one - foreign key to the source model (this would be group in our example), or you must explicitly specify the foreign keys django should use for the relationship using manytomanyfield.through_fields.. Django modelform foreignkey update. in django i have a complex query where i need only the unique values through a foreign key, is this possible? 3. related name in parent model in django if inherited in other model. 1. how to use two model forms on one view. 1. how to define mode with generic foreignkey in django.. Regardless of whether you define a primary key field yourself, or let django supply one for you, each model will have a property called pk. it behaves like a normal attribute on the model, but is actually an alias for whichever attribute is the primary key field for the model..
More than one foreign key to the same model