I have 3 models:
class Mixture(models.Model):
mixture_name = models.TextField()
class Contact(models.Model):
last_name = models.CharField()
first_name = models.CharField()
class ContactPerson(models.Model):
mixture = models.ForeignKey(
Mixture,
on_delete = models.CASCADE,
)
person = models.ForeignKey(
Contact,
on_delete = models.PROTECT,
)
These are my forms:
class MixtureForm(ModelForm):
class Meta:
model = Mixture
fields = [
'mixture_name',
]
class ContactPersonForm(ModelForm):
class Meta:
model: ContactPerson
fields = ['person']
ContactPersonFormset = inlineformset_factory(
Mixture, ContactPerson, form = ContactPersonForm,
extra = 0, can_delete = True, can_delete_extra = True,
)
Is it possible to create formset of ContactForms (model Contact) on the MixtureForm?