Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/api/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class MyModelAdmin(ExtraButtonsMixin, admin.ModelAdmin):
bool or callable show/hide button. The callable takes the `ButtonWidget` instance as a unique argument ; this argument gives access to the `request`, the template `context`, and the `original` object the is being edited in the admin.

`permission` (defaults to `None`):
Django permission code needed to access the view and display the button, or a callable that takes the `request` and the edited `object` as arguments and that must return a `bool`.
Django permission code needed to access the view and display the button, or a callable that takes the `request`, edited `object`, and `handler` as arguments and that must return a `bool`.

!!! Note

Expand Down Expand Up @@ -102,7 +102,7 @@ Buttons with custom permission, one for `change_list` and other for `change_form
@register(MyModel)
class MyModelAdmin(ExtraButtonsMixin, admin.ModelAdmin):

@button(permission=lambda request, obj: request.user.is_superuser)
@button(permission=lambda request, obj, handler: request.user.is_superuser)
def delete_all(self, request):
pass

Expand All @@ -123,7 +123,7 @@ Two complex buttons, one for `change_list` with custom permission, and one for `
@register(MyModel)
class MyModelAdmin(ExtraButtonsMixin, admin.ModelAdmin):

@button(permission=lambda request, obj: request.user.is_superuser,
@button(permission=lambda request, obj, handler: request.user.is_superuser,
html_attrs={'style': 'background-color:var(--button-bg)'},
label=_('Delete All Records'),
)
Expand Down
Loading