1
1
# Signals
2
2
3
- | app| provides the following signals:
3
+ {{ app}} provides the following signals:
4
4
5
5
* [[ #adminaction_requested]]
6
6
* [[ #adminaction_start]]
@@ -13,15 +13,18 @@ Sent when the action is requested (ie click 'Go' in the admin changelist view).
13
13
The handler can raise a :ref:` actioninterrupted ` to interrupt
14
14
the action's execution. The handler can rely on the following parameter:
15
15
16
+
16
17
* sender: [ django.db.models.Model] [ ]
17
18
* action: string. name of the action
18
- * request: [ HttpRequest ] ( https:// django.readthedocs.io/en/5.1.x/ref/request-response.html#httprequest-objects )
19
- * queryset: [ Queryset ] ( https:// django.readthedocs.io/en/5.1.x/ref/ models/querysets.html )
19
+ * request: [ django.http.HttpRequest ] [ ]
20
+ * queryset: [ django.db. models.query.QuerySet ] [ ]
20
21
* modeladmin: [ django.contrib.admin.ModelAdmin] [ ]
21
22
23
+
22
24
Example::
23
25
``` python
24
26
27
+ from adminactions.exceptions import ActionInterrupted
25
28
from adminactions.signals import adminaction_requested
26
29
27
30
def myhandler (sender , action , request , queryset , modeladmin , ** kwargs ):
@@ -38,11 +41,11 @@ Sent after the form has been validated (ie click 'Apply' in the action Form),
38
41
The handler can raise a :ref:`actioninterrupted` to avoid the stop execution.
39
42
The handler can rely on the following parameter:
40
43
41
- * sender: : class : ` django:django .db.models.Model`
44
+ * sender: [ django.db.models.Model][]
42
45
* action: string. name of the action
43
- * request: : class : ` django:django.core.httpd. HttpRequest`
44
- * queryset: : class : ` django:django .db.models.query.Queryset`
45
- * modeladmin: : class : ` django:django .contrib.admin.ModelAdmin`
46
+ * request: [ django.http. HttpRequest][]
47
+ * queryset: [ django.db.models.query.QuerySet][]
48
+ * modeladmin: [ django.contrib.admin.ModelAdmin][]
46
49
* form: :class :`django:django.forms.Form`
47
50
48
51
Example
@@ -66,11 +69,39 @@ adminaction_start.connect(myhandler, sender=MyModel, action='export`)
66
69
Sent ** after** the successfully execution of the action.
67
70
The handler can rely on the following parameter:
68
71
69
- * sender: : class : ` django:django .db.models.Model`
72
+ * sender: [ django.db.models.Model][]
70
73
* action: string. name of the action
71
- * request: : class : ` django:django.core.httpd. HttpRequest`
72
- * queryset: : class : ` django:django .db.models.query.Queryset`
73
- * modeladmin: : class : ` django:django .contrib.admin.ModelAdmin`
74
- * form: : class : ` django:django .forms.Form`
74
+ * request: [ django.http. HttpRequest][]
75
+ * queryset: [ django.db.models.query.QuerySet][]
76
+ * modeladmin: [ django.contrib.admin.ModelAdmin][]
77
+ * form: [ django.forms.Form][]
75
78
* errors: dict
76
79
* updated: int
80
+
81
+
82
+
83
+
84
+ # # mass_update_process
85
+
86
+
87
+ Sent ** before** the record is updated:
88
+ The handler can rely on the following parameter:
89
+
90
+ * sender: [django.db.models.Model][]
91
+ * request: [django.http.HttpRequest][]
92
+ * queryset: [django.db.models.query.QuerySet][]
93
+
94
+ Es:
95
+ ```python
96
+ from django.contrib.auth.models import User
97
+ from django.dispatch import receiver
98
+ from adminactions.signals import mass_update_process
99
+ from adminactions.exceptions import MassUpdateSkipRecordError
100
+
101
+
102
+ @ receiver(mass_update_process, sender = User)
103
+ def my_handler(sender, record: User, ** kwargs):
104
+ if record.is_superuser:
105
+ raise MassUpdateSkipRecordError
106
+
107
+ ```
0 commit comments