Skip to content

Commit 0894887

Browse files
committed
add a way to get a new 'attrs' attribute into the template
1 parent a46a311 commit 0894887

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

Diff for: django_object_actions/templates/django_object_actions/change_form.html

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{% block object-tools-items %}
55
{% for tool in objectactions %}
66
<li class="objectaction-item" data-tool-name="{{ tool.name }}">
7+
{# DELETEME #} {{ tool.attrs }}
78
<a href='tools/{{ tool.name }}/' title="{{ tool.short_description }}">
89
{{ tool.label|capfirst }}
910
</a>

Diff for: django_object_actions/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def to_dict(tool_name):
4242
return dict(
4343
name=tool_name,
4444
label=getattr(tool, 'label', tool_name),
45+
attrs=getattr(tool, 'attrs', None),
4546
short_description=getattr(tool, 'short_description', ''))
4647

4748
context['objectactions'] = [to_dict(x) for x in self.objectactions]

Diff for: example_project/polls/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def increment_vote(self, request, queryset):
1717
queryset.update(votes=F('votes') + 1)
1818
increment_vote.short_description = "+1"
1919
increment_vote.label = "vote++"
20+
increment_vote.attrs = {
21+
'test': 'foo',
22+
}
2023

2124
def decrement_vote(self, request, obj):
2225
obj.votes -= 1

0 commit comments

Comments
 (0)