Pre-populate an inline FormSet?

后端 未结 10 1558
自闭症患者
自闭症患者 2020-11-30 18:25

I\'m working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here\'s the model

10条回答
  •  臣服心动
    2020-11-30 19:14

    I ran into this question -6 years later- , and we are on Django 1.8 now.

    Still no perfectly clean , short answer to the question.

    The issue lies in the ModelAdmin._create_formsets() github ; My Solution is to override it, and inject the initial data i want somewhere around the highlighted lines in the github link .

    I also had to override the InlineModelAdmin.get_extra() in order "have room" for the initial data provided. Left default it will display only 3 of the initial data

    I believe there should be a more cleaner answer in the upcoming versions

提交回复
热议问题