Display model URL in admin
If the model has a get_absolute_url()
method, there should automatically be a 'View on site' button at the top right of the admin detail screen.
For the list view, you can easily add a method to the list of fields shown:
class MyAdmin(admin.ModelAdmin):
list_display=('name', 'anotherfield', 'show_url')
def show_url(self, instance):
return '<a href="%s">View on site</a>' % (instance.get_absolute_url())
show_url.allow_tags = True