Django Newbie working on a form to collect information for a carpool app. In this form, a family is specifying which “legs” of a carpool for which their child needs a ride. The Leg model looks like this:
class Leg(models.Model):
drive_date = models.DateField()
startpoint = models.CharField(max_length=50)
endpoint = models.CharField(max_length=50)
start_time = models.TimeField()
riders = models.ManyToManyField(Rider, blank=True)
drivers = models.ManyToManyField(Driver, blank=True)
carpool = models.ForeignKey(Carpool)
A unique form will be generated for each rider. The form will look like this: For each leg in a carpool, it will have actual uneditable data for the drive_date, startpoint, start_time (this information is already known). Then they’ll have a checkbox to indicate whether or not the rider needs a ride for that leg or not. If the box is checked, that rider gets added to that leg when the form is submitted.
I’ve looked into model formsets, and at some other methods for creating “dynamic” django forms, but having a hard time making anything work. Any advice on the best approach to show all the legs of a carpool on the same form, and include the rider checkbox, is much appreciated. if there’s already a good example of something like this, I’d sincerely appreciate a pointer to it.
Thanks!
For this instance, I gave up on forms and formsets and built custom templates from scratch