The app I'm creating requires instances of lessons to be created. For each lesson, any number of instructors can be assigned each with a specific user-inputted role.
For example:
- Lesson 1 has the following instructors
- role: head, name: Bob
- role: example, name: Adam
- role: assistant, name: Joy
Because the roles are unknown and the amount of instructors are unknown, the form must be able to accept a list of 'tuples'. Each tuple would then need a textfield and a select field (selecting form a list of instructors).
The data would then be saved in this model:
class MapInstructorTeach(models.Model):
teach = models.ForeignKey(Teach, on_delete=models.CASCADE)
instructor = models.ForeignKey(Instructor, on_delete=models.CASCADE)
role = models.CharField(max_length=32)
The Teach
model is just a model specifying the name of the lesson. The instructor
model is a list of instructors.
How would I go about creating the forms.py class and the html for something like this? I don't even know where to begin.
Attempts jQuery infinite input form I've tried using the above method to generate the fields in the front end but couldn't figure out a way to link the input fields to the backend.