Django signal on update via Django admin

I have some content in my database which is managed using Django admin. Now, I want to send a signal whenever any data is updated using django admin for those particular models.

I can’t use post_save signals because django admin does not call the save method of those models.

How can I do this? Please help!

Can you explain more? I ran a quick test on one of my projects. I added the following post_save handler.

@receiver(post_save, sender=CourseTask)
def check_signal(sender, instance, created, **kwargs):
    print("Hello from signal handler")

Then I created a new CourseTask from my admin page. In my logs, I got:

4:37:32 PM web.1 |  Hello from signal handler

I think this makes it clear that post_save does run from the admin so I’m not clear how why your setup is not working. If you can provide more context, that might be helpful in figuring out your problem.

I am working with Django 4.1 and python 9.12. I created my model register it in the admin, create a folder signals, then a file where I registered my signal but when I update or create within django-admin I cannot see the signal be called. I tested post_save, pre_save but none of these options work.

@receiver(pre_save, sender=TestModel)
def check_signal(sender, instance, **kwargs):
    print("Testing signal call ....")

Please post the contents of every file that you edited to create and register your signal handler. There are lots of different ways to set these up, and the details can get “picky”.

UPDATE: I inported the signal in the ready() method of AppConfig now it is working

# main_app/apps.py
from django.apps import AppConfig

class MainAppConfig(AppConfig):
    name = 'main_app'

    def ready(self):
        from main_app.signals import *