Django: sending update signal
from django.dispatch import Signal
post_update = Signal()
class MyCustomQuerySet(models.query.QuerySet):
def update(self, kwargs):
super(MyCustomQuerySet, self).update(kwargs)
post_update.send(sender=self.model)
class MyCustomManager(models.Manager):
def getqueryset(self):
return MyCustomQuerySet(self.model, using=self._db)
then you can declare your models like:
class MyCustomModel(models.Model):
objects = MyCustomManager()
now whenever you call MyCustomModel.objects.update(...) it'll trigger the post_update signal.
Written by Marconi Moreto
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#