Skip to content Skip to sidebar Skip to footer

Django How Does Django Know Which Formset Is Which

Assuming I have a model that directly correspond to a ModelFormset. Assuming three instances of the model are saved in the database. Assuming I loaded the ModelFormset with initia

Solution 1:

If you have an existing instance in ModelForm (or in a set of them inside ModelFormset), then there's a hidden field with the value of the primary key for the record.

Each ModelForm has also a unique suffix for each the field, which helps distinguish which fields belongs to the same model.


Post a Comment for "Django How Does Django Know Which Formset Is Which"