Django Dynamically Adding Form So That it is Aware of it's Parent -


The first question.

I have a problem creating a structure to create an event with many events (user specifies how many) activities and each activity can be more than once, I want my appearance, it The structure is:

  \ - event activity 1 time 1 time 2 time 3 activity 2 time 1 time 2 time 3  

where users can add more activities And can add more for each activity May include.

models.py

  def event (models.Model): # relevant events not deaf activity (models.Model): event = model. Forvinke (event) # more irrelevant stuff def activity time (models.Model): activity = model. Freigaki (activity) start_time = model Timefield () end_time = models.TimeField () # more irrelevant stuff  

I am using model formats to represent event, activity, activity. When I add entries to the database, then I want to be 'aware' of my related activity every time I am not sure how to implement it. I have not got luck with inline formats, but probably because I do not understand anything.

An inline formattette is a type of model variant.

You will use a inlineformset_factory to create your own format. If you can see the document here:

... you will see that it supports two arguments max_num and extra together Determine how many additional blank forms will be added in the format.

If you are Google for 'Django Dynamic Format' then you will find several packages that provide some additional JavaScript so that additional 'extra' can add blank formattes to the front side (as you would in Django Admin can do).


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -