File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -113,15 +113,15 @@ def anonymize(self, commit=True):
113
113
if commit:
114
114
self.save()
115
115
"""
116
+ signals .anonymize .send (
117
+ sender = self .__class__ , instance = self
118
+ )
116
119
self .email = None
117
120
self .first_name = ""
118
121
self .last_name = ""
119
122
update_fields = ["email" , "first_name" , "last_name" ]
120
123
if commit :
121
124
self .save (update_fields = update_fields )
122
- signals .anonymize .send (
123
- sender = self .__class__ , instance = self , update_fields = tuple (update_fields )
124
- )
125
125
return update_fields
126
126
127
127
Original file line number Diff line number Diff line change 4
4
"""
5
5
Signal that is emitted when a user and all their data should be anonymized.
6
6
7
+ The signal is emitted before the private date is delete on the instance,
8
+ thus the receiver can still access the data. The receiver should usually
9
+ not alter the instance, but only later related data. We recommend overriding
10
+ the anonymize method to modify the instance.
11
+
7
12
Usage::
8
13
9
14
from django.dispatch import receiver
12
17
13
18
14
19
@receiver(anonymize, sender=EmailUser)
15
- def anonymize_user(sender, instance, update_fields, **kwargs):
20
+ def anonymize_user(sender, instance, **kwargs):
16
21
# Do something with related user data
17
22
instance.related_model.delete()
18
23
You can’t perform that action at this time.
0 commit comments