Skip to content

Commit

Permalink
add documentation of .attrs attr
Browse files Browse the repository at this point in the history
  • Loading branch information
crccheck committed Feb 12, 2014
1 parent 6d798d5 commit 9d38714
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
``````````````````````

Expand Down

0 comments on commit 9d38714

Please sign in to comment.