1
- Django Object Actions
2
- =====================
1
+ # Django Object Actions
3
2
4
3
[ ![ CI] ( https://github.com/crccheck/django-object-actions/actions/workflows/ci.yml/badge.svg?branch=master )] ( https://github.com/crccheck/django-object-actions/actions/workflows/ci.yml?query=branch%3Amaster )
5
4
6
5
If you've ever tried making admin object tools you may have thought, "why can't
7
6
this be as easy as making Django Admin Actions?" Well now they can be.
8
7
9
-
10
- Quick-Start Guide
11
- -----------------
8
+ ## Quick-Start Guide
12
9
13
10
Install Django Object Actions:
14
11
@@ -30,18 +27,17 @@ class ArticleAdmin(DjangoObjectActions, admin.ModelAdmin):
30
27
publish_obj(obj)
31
28
32
29
change_actions = (' publish_this' , )
30
+ changelist_actions = (' ...' , )
33
31
```
34
32
33
+ ## Usage
35
34
36
- Usage
37
- -----
38
-
39
- Defining new &* tool actions* is just like defining regular [ admin actions] . The
35
+ Defining new &_ tool actions_ is just like defining regular [ admin actions] . The
40
36
major difference is the functions for ` django-object-actions ` will take an
41
- object instance instead of a queryset (see * Re -using Admin Actions * below).
37
+ object instance instead of a queryset (see _ Re -using Admin Actions _ below).
42
38
43
- * Tool actions * are exposed by putting them in a ` change_actions ` attribute in
44
- your ` admin.ModelAdmin ` . You can also add * tool actions * to the main changelist
39
+ _ Tool actions _ are exposed by putting them in a ` change_actions ` attribute in
40
+ your ` admin.ModelAdmin ` . You can also add _ tool actions _ to the main changelist
45
41
views too. There, you'll get a queryset like a regular [ admin action] [ admin actions ] :
46
42
47
43
``` python
@@ -72,7 +68,7 @@ you'll need to take extra care because `django-object-actions` uses them too.
72
68
73
69
### Re-using Admin Actions
74
70
75
- If you would like a preexisting admin action to also be an * object action * , add
71
+ If you would like a preexisting admin action to also be an _ object action _ , add
76
72
the ` takes_instance_or_queryset ` decorator to convert object instances into a
77
73
queryset and pass querysets:
78
74
@@ -92,7 +88,7 @@ class RobotAdmin(DjangoObjectActions, admin.ModelAdmin):
92
88
93
89
[ admin actions ] : https://docs.djangoproject.com/en/stable/ref/contrib/admin/actions/
94
90
95
- ### Customizing * Object Actions *
91
+ ### Customizing _ Object Actions _
96
92
97
93
To give the action some a helpful title tooltip, you can use the ` action ` decorator
98
94
and set the description argument.
@@ -191,9 +187,7 @@ If you don't intend to use the template customizations at all, don't
191
187
add ` django_object_actions ` to your ` INSTALLED_APPS ` at all and use
192
188
` BaseDjangoObjectActions ` instead of ` DjangoObjectActions ` .
193
189
194
-
195
- More Examples
196
- -------------
190
+ ## More Examples
197
191
198
192
Making an action that links off-site:
199
193
@@ -203,9 +197,7 @@ def external_link(self, request, obj):
203
197
return HttpResponseRedirect(f ' https://example.com/ { obj.id} ' )
204
198
```
205
199
206
-
207
- Limitations
208
- -----------
200
+ ## Limitations
209
201
210
202
1 . ` django-object-actions ` expects functions to be methods of the model
211
203
admin. While Django gives you a lot more options for their admin
@@ -218,25 +210,19 @@ Limitations
218
210
your own actions irregardless of what this provides. Better default
219
211
security is planned for the future.
220
212
221
-
222
- Python and Django compatibility
223
- -------------------------------
213
+ ## Python and Django compatibility
224
214
225
215
See [ ` ci.yml ` ] ( ./.github/workflows/ci.yml ) for which Python and Django versions this supports.
226
216
227
-
228
- Demo Admin & Docker images
229
- --------------------------
217
+ ## Demo Admin & Docker images
230
218
231
219
You can try the demo admin against several versions of Django with these Docker
232
220
images: https://hub.docker.com/r/crccheck/django-object-actions/tags
233
221
234
222
This runs the example Django project in ` ./example_project ` based on the "polls"
235
223
tutorial. ` admin.py ` demos what you can do with this app.
236
224
237
-
238
- Development
239
- -----------
225
+ ## Development
240
226
241
227
Getting started:
242
228
@@ -256,9 +242,7 @@ view the `Makefile` to see what other things you can do.
256
242
Some commands assume you are in the virtualenv. If you see
257
243
"ModuleNotFoundError"s, try running ` poetry shell ` first.
258
244
259
-
260
- Similar Packages
261
- ----------------
245
+ ## Similar Packages
262
246
263
247
If you want an actions menu for each row of your changelist, check out [ Django
264
248
Admin Row Actions] ( https://github.com/DjangoAdminHackers/django-admin-row-actions ) .
0 commit comments