first question.
I'm having a problem with creating a structure of creating an event with several (user specifies how many) activities and each activity may occur more than once. The structure I'd like my form to have is:
\-- Event
Activity 1
Time 1
Time 2
Time 3
Activity 2
Time 1
Time 2
Time 3
Where the user can add more activities, and for each activities more times.
models.py
def Event(models.Model):
# not relevant attrs
def Activity(models.Model):
event = models.ForeignKey(Event)
# more irrelevant stuff
def ActivityTime(models.Model):
activity = models.ForeignKey(Activity)
start_time = models.TimeField()
end_time = models.TimeField()
# more irrelevant stuff
I'm using modelforms to represent Event, Activity, ActivityTime. I want each time to be 'aware' of its corresponding activity for when I add the entries to the database. I'm not sure how to implement this. I haven't had luck with inline formsets but maybe because there's something I’m not understanding.