1๐
โ
Inline formsets is a small abstraction layer on top of model formsets. These simplify the case of working with related objects via a foreign key.
It seems that inline formsets are exactly what you want.
Optionally you can specify how many DeliveryRequestBikes
you want to allow for a DeliveryRequests
.
Give them a try with:
from django.forms.models import inlineformset_factory
DeliveryRequestBikesFormSet = inlineformset_factory(DeliveryRequests, DeliveryRequestBikes, fk_name="deliveryrequest")
๐คandrea.ge
Source:stackexchange.com