Created
March 27, 2022 08:53
-
-
Save siumhossain/09daff98148877d4f47bec559b72ffd0 to your computer and use it in GitHub Desktop.
Update something in django model and check by signal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db.models.signals import post_save,pre_save | |
| from django.dispatch import receiver | |
| @receiver(pre_save, sender=Product) | |
| def pre_save_user(sender, instance, **kwargs): | |
| if not instance._state.adding: | |
| print ('this is an update') | |
| else: | |
| print ('this is an insert') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment