Adding additional links to Django’s Admin

If you’re like me, you’d like to add some new links to one of the Django admin lists (perhaps to delete right from the list or to direct a user to a custom made view).

Here’s the relevant code:

To your model, add:

def some_name(self):
return '<a href="/some/admin/url/here/%s/">Link Name</a>' % self.id
some_name.allow_tags = True #this is to allow HTML tags.
some_name.short_description = 'Table Header Name here'

And then just add “some_name” to your “class Admin” in the “list_display” list. Nice and neat.

Comments are closed.