1👍
✅
You could add an name/id to each form using a handful of different techniques, though you probably want to use a formset
.
https://docs.djangoproject.com/en/dev/topics/forms/formsets/
These can be confusing initially if you’ve been looking at forms, but so long as you understand that it’s another layer of abstraction and you need to take care of which ModelForm
instance you are working with.
Specifically you may want to use django.forms.models.modelform_factory
.
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#model-formsets
Usage is really easy, but if you want to do anything interesting with the forms it can be more difficult:
>>> from django.forms.models import modelformset_factory
>>> AuthorFormSet = modelformset_factory(Author)
Source:stackexchange.com