Dynamic fields in Django Admin

后端 未结 9 1482
失恋的感觉
失恋的感觉 2020-12-05 05:18

I want to have additional fields regarding value of one field. Therefor I build a custom admin form to add some new fields.

Related to the blogpost of jacobian 1 thi

9条回答
  •  悲哀的现实
    2020-12-05 05:32

    I for a long time could not solve a problem with dynamic addition of fields. The solution "little_birdie" really works. Thank you Birdie)) The only nuance is: "Self.declared_fieldsets" should be replaced with "self.fieldsets".

    #kwargs['fields'] =  flatten_fieldsets(self.declared_fieldsets)
    kwargs['fields'] =  flatten_fieldsets(self.fieldsets)
    

    I used version 1.10. Perhaps something has changed.

    If someone finds an even simpler and elegant solution, show here.

    Thanks to all )))

提交回复
热议问题