I am using .post_save
in some of my models to do some time consuming works. I want to track which user is actually sending the signals. Is there any way to do that?
Asked
Active
Viewed 916 times
0

Anonymous Coder
- 119
- 5
-
This is actually not possible. Compare [this question](https://stackoverflow.com/a/4716440/4344683). – Shezan Kazi Apr 06 '20 at 07:52
2 Answers
0
one solution is put user like a field of the model that you are saving user = models.ForeignKey(User)
to use after in the signal.

Diego Puente
- 1,964
- 20
- 23
-1
try:
from django.db.models.signals import post_save
from django.contrib.auth.models import User
@receiver(post_save, sender=User)
def user_saved(sender, instance, **kwargs):
# here, instance is the User instance that was saved in the database
time_consuming_work(instance)
Hope this helps.

alfonso.kim
- 2,844
- 4
- 32
- 37
-
I do not think this is what the OP was referring to. The question was about the `request.user` if you so will – Shezan Kazi Apr 06 '20 at 07:52