Skip to content

Commit f92464e

Browse files
authored
docs: update README style (#157)
To reduce future diffs from autoformat
1 parent e73b4d0 commit f92464e

File tree

2 files changed

+19
-36
lines changed

2 files changed

+19
-36
lines changed

README.md

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
Django Object Actions
2-
=====================
1+
# Django Object Actions
32

43
[![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)
54

65
If you've ever tried making admin object tools you may have thought, "why can't
76
this be as easy as making Django Admin Actions?" Well now they can be.
87

9-
10-
Quick-Start Guide
11-
-----------------
8+
## Quick-Start Guide
129

1310
Install Django Object Actions:
1411

@@ -30,18 +27,17 @@ class ArticleAdmin(DjangoObjectActions, admin.ModelAdmin):
3027
publish_obj(obj)
3128

3229
change_actions = ('publish_this', )
30+
changelist_actions = ('...', )
3331
```
3432

33+
## Usage
3534

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
4036
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).
4238

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
4541
views too. There, you'll get a queryset like a regular [admin action][admin actions]:
4642

4743
```python
@@ -72,7 +68,7 @@ you'll need to take extra care because `django-object-actions` uses them too.
7268

7369
### Re-using Admin Actions
7470

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
7672
the `takes_instance_or_queryset` decorator to convert object instances into a
7773
queryset and pass querysets:
7874

@@ -92,7 +88,7 @@ class RobotAdmin(DjangoObjectActions, admin.ModelAdmin):
9288

9389
[admin actions]: https://docs.djangoproject.com/en/stable/ref/contrib/admin/actions/
9490

95-
### Customizing *Object Actions*
91+
### Customizing _Object Actions_
9692

9793
To give the action some a helpful title tooltip, you can use the `action` decorator
9894
and set the description argument.
@@ -191,9 +187,7 @@ If you don't intend to use the template customizations at all, don't
191187
add `django_object_actions` to your `INSTALLED_APPS` at all and use
192188
`BaseDjangoObjectActions` instead of `DjangoObjectActions`.
193189

194-
195-
More Examples
196-
-------------
190+
## More Examples
197191

198192
Making an action that links off-site:
199193

@@ -203,9 +197,7 @@ def external_link(self, request, obj):
203197
return HttpResponseRedirect(f'https://example.com/{obj.id}')
204198
```
205199

206-
207-
Limitations
208-
-----------
200+
## Limitations
209201

210202
1. `django-object-actions` expects functions to be methods of the model
211203
admin. While Django gives you a lot more options for their admin
@@ -218,25 +210,19 @@ Limitations
218210
your own actions irregardless of what this provides. Better default
219211
security is planned for the future.
220212

221-
222-
Python and Django compatibility
223-
-------------------------------
213+
## Python and Django compatibility
224214

225215
See [`ci.yml`](./.github/workflows/ci.yml) for which Python and Django versions this supports.
226216

227-
228-
Demo Admin & Docker images
229-
--------------------------
217+
## Demo Admin & Docker images
230218

231219
You can try the demo admin against several versions of Django with these Docker
232220
images: https://hub.docker.com/r/crccheck/django-object-actions/tags
233221

234222
This runs the example Django project in `./example_project` based on the "polls"
235223
tutorial. `admin.py` demos what you can do with this app.
236224

237-
238-
Development
239-
-----------
225+
## Development
240226

241227
Getting started:
242228

@@ -256,9 +242,7 @@ view the `Makefile` to see what other things you can do.
256242
Some commands assume you are in the virtualenv. If you see
257243
"ModuleNotFoundError"s, try running `poetry shell` first.
258244

259-
260-
Similar Packages
261-
----------------
245+
## Similar Packages
262246

263247
If you want an actions menu for each row of your changelist, check out [Django
264248
Admin Row Actions](https://github.com/DjangoAdminHackers/django-admin-row-actions).

django_object_actions/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def action(
317317
function=None, *, permissions=None, description=None, label=None, attrs=None
318318
):
319319
"""
320-
Conveniently add attributes to an action function::
320+
Conveniently add attributes to an action function:
321321
322322
@action(
323323
permissions=['publish'],
@@ -328,7 +328,7 @@ def make_published(self, request, queryset):
328328
queryset.update(status='p')
329329
330330
This is equivalent to setting some attributes (with the original, longer
331-
names) on the function directly::
331+
names) on the function directly:
332332
333333
def make_published(self, request, queryset):
334334
queryset.update(status='p')
@@ -337,8 +337,7 @@ def make_published(self, request, queryset):
337337
make_published.label = 'Publish'
338338
339339
This is the django-object-actions equivalent of
340-
https://docs.djangoproject.com
341-
/en/dev/ref/contrib/admin/actions/#django.contrib.admin.action
340+
https://docs.djangoproject.com/en/stable/ref/contrib/admin/actions/#django.contrib.admin.action
342341
"""
343342

344343
def decorator(func):

0 commit comments

Comments
 (0)