How do I add a link from the Django admin page of one object to the admin page of a related object?

Use readonly_fields:

class MyInline(admin.TabularInline):
    model = MyModel
    readonly_fields = ['link']

    def link(self, obj):
        url = reverse(...)
        return mark_safe("<a href="https://stackoverflow.com/questions/9919780/%s">edit</a>" % url)

    # the following is necessary if 'link' method is also used in list_display
    link.allow_tags = True

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)