Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

how to auto add inline models in django admin page

i have a model in django admin, and that model have 2 inline models inside it as shown :

@ admin.register(Transaction)
   class TransactionAdmin(admin.ModelAdmin):
   inlines = [FamilyGroupInline, FamilyMemberInline]
   fieldsets = (
       (None, {
           'fields': ('complete',),
       }),
       ('Transaction Details', {
           'fields': ('chp_reference', 'income_period', 'property_market_rent', 
       'rent_effective_date', 'number_of_family_group',),
       }),
       ('Report', {
           'classes': ('collapse',),
           'fields': ('report',),
       }),
   )
  

im trying to customize the Transaction admin page, i want the two inline models be added automatically once i start a new Transaction, and dont have to click "add another ..." button enter image description here

what is the best approach to achieve that ? would appreciate your help!

question from:https://stackoverflow.com/questions/65644708/how-to-auto-add-inline-models-in-django-admin-page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...