Reputation: 7154
I've got model
class Book(models.Model):
...
accepted = models.BooleanField()
and admin
class BookAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'accepted')
actions = ('change_accepted',)
def change_accepted(self, request, queryset):
queryset.update(accepted=True)
This create custom action from scrollable action menu. I've need something like this: http://www.theotherblog.com/wp-content/uploads/2009/06/django_admin.jpg (last column). I mean - action from list_display. Is it possible?
Sorry for my english.
Upvotes: 0
Views: 693
Reputation: 50806
I think you're rather looking for calling a method on the admin class through list_display
which should display a link in the current row than for an admin action:
class BookAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'accepted', 'my_linK')
def my_link(self, obj):
return "<a href="%s">View on site</a>" % obj.get_absolute_url()
Upvotes: 1