You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/api/button.md
+35-39Lines changed: 35 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,58 +33,56 @@ class MyModelAdmin(ExtraButtonsMixin, admin.ModelAdmin):
33
33
34
34
!!! Note
35
35
36
-
AEB try to understand if a button should appear in the `change_form` and/or in the `change_list` page.
37
-
If the decorated method has only one argument (es. `def scan(self, request)`), the button will only be visible
38
-
on the `change_list` page, if it contains more that one argumente (es. `def scan(self, request, pk)`)
36
+
AEB can guess if the button should appear in the `change_form` and/or in the `change_list` page:
37
+
if the decorated method has only one argument (es. `def scan(self, request)`), the button will only be visible
38
+
on the `change_list` page ; while if it contains more that one argument (es. `def scan(self, request, pk)`)
39
39
the button will be visible in the `change_form` page.
40
40
41
41
## Options
42
42
43
-
change_form: `None`
44
-
: set to `True` do show the button on the `change_form` page
45
-
If set to `None` (default), use method signature to display the button
43
+
`change_form` (defaults to `None`):
44
+
Set to `True` do show the button on the `change_form` page.
45
+
If set to `None` (default), use method signature to display the button.
46
46
47
-
change_list: `None`
48
-
: set to `True` do show the button on the `change_list` page
49
-
If set to `None` (default), use method signature to display the button
47
+
`change_list` (defaults to `None`):
48
+
Set to `True` do show the button on the `change_list` page.
49
+
If set to `None` (default), use method signature to display the button.
50
50
51
-
disable_on_click: `True`
52
-
: automatically disable button on click() to prevent unintentional double processing
51
+
`disable_on_click` (defaults to `True`):
52
+
Automatically disable button on `click` to prevent unintentional double processing.
53
53
54
-
disable_on_edit: `True`
55
-
: automatically disable button when any FORM in page is modified
54
+
`disable_on_edit` (defaults to `True`):
55
+
Automatically disable button when any FORM in page is modified.
56
56
57
-
enabled: `True`
58
-
: bool or callable to set enable status
57
+
`enabled` (defaults to `True`):
58
+
bool or callable to set enable status. 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.
59
59
60
-
html_attrs: `{}`
61
-
: Dictionary of html tags to use in button rendering.
60
+
`html_attrs` (defaults to `{}`):
61
+
Dictionary of html tags to use in button rendering.
62
62
63
-
label: `decorated method name`
64
-
: button label
63
+
`label` (defaults to `decorated method name`):
64
+
button label.
65
65
66
-
visible: `True`
67
-
: bool or callable show/hide button
66
+
`pattern` (defaults to `<function_name>/<path:arg1>/<path:arg2>/....`):
67
+
url pattern to use for the url generation.
68
68
69
+
`visible` (defaults to `True`):
70
+
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.
71
+
72
+
`permission` (defaults to `None`):
73
+
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`.
69
74
70
75
!!! Note
71
76
72
77
`id` is automacally set if not provided,
73
78
`class` is updated/set based on `disable_on_click` and `disable_on_edit` values
0 commit comments