On Friday, January 21, 2011 1:03:12 PM UTC, Ivo Brodien wrote: > > How can I create an action for an object in the change list? > > At the moment, I created an admin action with an intermediate page and I am > only selecting on object, but that is not nice and too complicated for the > workflow. > > I thought the way to go would be to put a little form inside the field_list > for each object. That form has the name of the action as the hidden field. I > haven’t tried it yet, but it should work. > > Any other ideas which might be less ‘hacky'? > > BTW: I want to be able to call the action without going in the change_view > where there is the “view on side” button for example. > > Thanks > ivo >
I usually do this by setting up a method to return an HTML link to a custom admin page, referencing that in the list_display tuple: class MyModelAdmin(admin.ModelAdmin): list_display = ('name', 'action_link') def action_link(self, obj): return "<a href='%s'>Do action on this object</a>" % reverse('action_view', args=(obj.pk,)) action_link.allow_tags = True -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.