Adding links to full change forms for inline items in django admin?

前端 未结 7 531
执念已碎
执念已碎 2021-01-31 02:36

I have a standard admin change form for an object, with the usual StackedInline forms for a ForeignKey relationship. I would like to be able to link each inline item to its corr

相关标签:
7条回答
  • 2021-01-31 03:11

    The currently accepted solution here is good work, but it's out of date.

    Since Django 1.3, there is a built-in property called show_change_link = True that addresses this issue.

    This can be added to any StackedInline or TabularInline object. For example:

    class ContactListInline(admin.TabularInline):
        model = ContactList
        fields = ('name', 'description', 'total_contacts',)
        readonly_fields = ('name', 'description', 'total_contacts',)
        show_change_link = True
    

    The result will be something line this:

    0 讨论(0)
提交回复
热议问题