0

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?

2 Answers2

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