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 corresponding full-sized change form, as the inline item has inlined items of its own, and I can't nest them.
I've tried everything from custom widgets to custom templates, and can't make anything work. So far, the "solutions" I've seen in the form of snippets just plain don't seem to work for inlines. I'm getting ready to try some DOM hacking with jQuery just to get it working and move on.
I hope I must be missing something very simple, as this seems like such a simple task!
Using Django 1.2.
There is a property called show_change_link
since Django 1.8.
I did something like the following in my admin.py:
from django.utils.html import format_html from django.core.urlresolvers import reverse class MyModelInline(admin.TabularInline): model = MyModel def admin_link(self, instance): url = reverse('admin:%s_%s_change' % (instance._meta.app_label, instance._meta.module_name), args=(instance.id,)) return format_html(u'<a href="{}">Edit</a>', url) # … or if you want to include other fields: return format_html(u'<a href="{}">Edit: {}</a>', url, instance.title) readonly_fields = ('admin_link',)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With