#models.py
class Legs:
left = TextField(default='-')
right = TextField(default='-')
class Animal:
#possibly, more fields
description = TextField()
front_legs = OneToOneField(Legs, related_name='front_animal')
back_legs = OneToOneField(Leg,s related_name='back_animal')
#forms.py
class LegsForm(ModelForm):
""""
Not needed, but declared to have the LegsForm name to use next.
""""
class Meta:
model = Legs
# form for Animal
How to create a ModelForm
for Animal
that incorporates all its fields and also handles the creation of the related objects using the two forms for the legs, i.e., LegsForm(prefix='front')
and LegsForm(prefix='back')
?