Skip to content

Commit

Permalink
doc using POST
Browse files Browse the repository at this point in the history
  • Loading branch information
crccheck committed Sep 9, 2024
1 parent 92ee519 commit 37d56e1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ArticleAdmin(DjangoObjectActions, admin.ModelAdmin):

## Usage

Defining new &_tool actions_ is just like defining regular [admin actions]. The
Defining new _tool actions_ is just like defining regular [admin actions]. The
major difference is the functions for `django-object-actions` will take an
object instance instead of a queryset (see _Re-using Admin Actions_ below).

Expand Down Expand Up @@ -176,6 +176,24 @@ def get_change_actions(self, request, object_id, form_url):

The same is true for changelist actions with `get_changelist_actions`.

### Using POST instead of GET for actions

⚠️ This is a beta feature and subject to change

Since actions usually change data, for safety and semantics, it would be
preferable that actions use a HTTP POST instead of a GET.

You can configure an action to only use POST with:

```python
@action(methods=("post",), button_type="form")
```

One caveat is Django's styling is pinned to anchor tags[^1], so to maintain visual
consistency with other actions, we have to use anchor tags too.

[^1]: https://github.com/django/django/blob/826ef006681eae1e9b4bd0e4f18fa13713025cba/django/contrib/admin/static/admin/css/base.css#L786

### Alternate Installation

You don't have to add this to `INSTALLED_APPS`, all you need to to do
Expand Down

0 comments on commit 37d56e1

Please sign in to comment.