Sometimes you may need to add one or more links for each table row in your admin changelist view. There are many ways to do it, and here we'ss see a simple one. So this post is nothing more than a tip.
In my case I had to add a link opening a pdf view of the model item detail, here comes my implementation:
from django.db import models from django.core.urlresolvers import reverse from django.utils.html import mark_safe class MyModel(models.Model): title = models.CharField('title', max_length=255) # ... def pdf_link(self): return mark_safe('<a class="grp-button" href="%s" target="blank">view pdf</a>' % reverse('archiviocr-opera-pdf', args=[self.id])) pdf_link.short_description = _('PDF')
- app/admin ...