Questions tagged [django-signals]

Django signals allow listeners to be registered for events within the framework. This allows decoupled handling of, for example, model deletions.

Django signals allow listeners to be registered for events within the framework. This allows decoupled handling of, for example, model deletions.

Quote from docs:

Django includes a “signal dispatcher” which helps allow decoupled applications get notified when actions occur elsewhere in the framework. In a nutshell, signals allow certain senders to notify a set of receivers that some action has taken place. They’re especially useful when many pieces of code may be interested in the same events.

See documentation.

877 questions
8
votes
3 answers

Sending and receiving signals in django models

I am using django 2.0.8 and Python 3.5. I want to be able to send and receive custom signals when an object is saved to the database. I have followed the Django documentation on listening to signals and also the core signals bundled with Django -…
Homunculus Reticulli
  • 65,167
  • 81
  • 216
  • 341
8
votes
0 answers

Django post_save signal not triggering from data migration

I am using post_save signal to trigger the creation of profile data for User instance. The problem is if I create a User object from data migration then the post_save signal isn't triggering. However, If I create User instance via shell or…
Cody
  • 2,480
  • 5
  • 31
  • 62
8
votes
1 answer

How to send a django signal from other signal

TL;DR: I need a way to trigger a custom signal after the post_save signal, automatically, is there any way of doing it? I'm currently developing a library for django that requires a lot of comes and goes with the post_save signal in django and I…
CastleDweller
  • 8,204
  • 13
  • 49
  • 69
8
votes
1 answer

Extending django-registration using signals

I have found here on stackoverflow a solution to extend django-registration with new fields using signals. Here's the link : http://dmitko.ru/?p=546 . I have created extended profile model, extended form, added required options to settings , defined…
crivateos
  • 925
  • 3
  • 10
  • 19
8
votes
4 answers

Check previous model value on save

I have a model that saves an Excursion. The user can change this excursion, but I need to know what the excursion was before he change it, because I keep track of how many "bookings" are made per excursion, and if you change your excursion, I need…
Harry
  • 13,091
  • 29
  • 107
  • 167
8
votes
3 answers

Django Signal via Decorator on Model Method?

I'm trying to do something like these proposed signal decorators. In addition to having a decorator that connects the decorated method to a signal (with the signal's sender as an argument to the decorator), I would like to use the decorator on…
Carl G
  • 17,394
  • 14
  • 91
  • 115
8
votes
1 answer

django signals: receiver and proxy model?

I set a receiver on a post_save signal and I was hoping catching the signals for all the proxy of my Model by setting the sender to the main Model but it does not seem to work: class MyObject(models.Model): .... class MyObjectProxy(MyObject): …
Michael
  • 8,357
  • 20
  • 58
  • 86
8
votes
4 answers

Django: What exactly are signals good for?

I have a tough time understanding how signals work into my application (and how they work period). These are three areas where I assume they would apply (with my current knowledge): Send XML to a remote server for reporting (after a transaction is…
orokusaki
  • 55,146
  • 59
  • 179
  • 257
7
votes
2 answers

Facebook like notification updates using django signal or notification

How can i use django-notifications or django-signals to make something like facebook updates notification that shows in the user profile if any other user likes or posts comments on user's blog or posts?
G Gill
  • 1,087
  • 1
  • 12
  • 24
7
votes
1 answer

Django: determine which user is deleting when using post_delete signal

I want admins to be notified when certain objects are deleted but I also want to determine which user is performing the delete. Is it possible? This is the code: # models.py # signal to notify admins when nodes are deleted from…
nemesisdesign
  • 8,159
  • 12
  • 58
  • 97
7
votes
1 answer

Is the post_save signal in Django atomic?

I really can't find anything solid in the docs. Lets say I'm doing something like this: from django.db.models.signals import post_save from django.dispatch import receiver class Item(models.Model): total_score = models.IntegerField() def…
darkhorse
  • 8,192
  • 21
  • 72
  • 148
7
votes
1 answer

Django signals dispatch_uid

I have a question regarding the usage of dispatch_uid for signals. Currently, I am preventing multiple usage of the signal by simply adding if not instance.order_reference. I wonder now if dispatch_uid has the same functionality and I can delete the…
user9252255
7
votes
3 answers

Detect a changed password in Django

When a user changes their password, I want to send a signal so that I can do some stuff on some models. How can I create this signal? I've looked at the post_save signal for User: post_save.connect(user_updated, sender=User) However, there doesn't…
43Tesseracts
  • 4,617
  • 8
  • 48
  • 94
7
votes
1 answer

Django: cannot get an Model instance from ForwardManyToOneDescriptor (ForeignKey)

I have the following code in accounts/signals/__init__.py: from django.db.models.signals import post_save from django.dispatch import receiver from orders.models import Order from accounts.models import Balance @receiver(post_save,…
Oleg Belousov
  • 9,981
  • 14
  • 72
  • 127
7
votes
2 answers

Django cascade delete and post_delete signal

In my application post_delete signals being recorded in a specific model and when it was removed. class A(models.Model): ... class B(models.Model): a = models.ForeignKey('A') class C(models.Model): b = models.ForeignKey('B') def…