From 9d38714c51d72c84d6ea1bdc4877339cb03643c1 Mon Sep 17 00:00:00 2001 From: crccheck Date: Wed, 12 Feb 2014 17:49:41 -0600 Subject: [PATCH] add documentation of .attrs attr --- README.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.rst b/README.rst index 14219e7..0e7ed3f 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,36 @@ If you would like an admin action to also be an object tool, add the objectactions = ['tighten_lug_nuts'] actions = ['tighten_lug_nuts'] +Customizing Admin Actions +````````````````````````` + +To give the action some a helpful title tooltip, add a ``short_description`` +attribute, similar to how admin actions work:: + + def increment_vote(self, request, obj): + obj.votes = obj.votes + 1 + obj.save() + increment_vote.short_description = "Increment the vote count by one" + +By default, Django Object Actions will guess what to label the button based on +the name of the function. You can override this with a ``label`` attribute:: + + def increment_vote(self, request, obj): + obj.votes = obj.votes + 1 + obj.save() + increment_vote.label = "Vote++" + +If you need even more control, you can add arbitrary attributes to the buttons +by adding a Django widget style `attrs` attribute:: + + def increment_vote(self, request, obj): + obj.votes = obj.votes + 1 + obj.save() + increment_vote.attrs = { + 'class': 'addlink', + } + + Alternate Installation ``````````````````````