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
0
votes
1 answer

Versioned model

I am thinking of how best to implement a model that cannot be modified (ie: each time the model data is modified, a new instance of the object is created and a reference is added to the previous instance to reflect the fact that the old object has…
wshyang
  • 53
  • 1
  • 4
0
votes
1 answer

Signals VS Celery task

So i have this scenario and quite not sure whether celery is the right tool for the job. I have to track the fifth order placed by a user to give them a coupon. Currently i have implemented a signal on the @receiver(pre_save, sender=Order) def…
Harrison
  • 188
  • 2
  • 9
0
votes
2 answers

Django, update rate, signals

class Thing (model.Models): name = models.CharField(max_length = 222) ratee = models.IntegerField(default = 0) ... class Rate(models.Model): thing = models.ForeignKey(Thing) user = models.ForeignKey(User) rate =…
0
votes
0 answers

How to automatically generate notification to user when events is added?

I have developed a website having functionality such as writing,posting ,user profiles, events & activities, offers..etc.I need to add one more functionality and i.e. Automatic push notification to the users about activities & events, offers and…
0
votes
2 answers

Django models override save and new field value from related objects

I have such Django models: class Car(models.Model): rating = models.PositiveIntegerField( default=0, verbose_name=_('Rating'), ) class ReportInfo(models.Model): car = models.ForeignKey( Car, …
Q-bart
  • 1,503
  • 4
  • 22
  • 41
0
votes
0 answers

Django trigger signal on bulk update

I'm aware that signals aren't triggered for bulk updates, however, I need this behaviour. I'm wondering which of these two ways is more efficient: qs = MyObject.objects.all() Do a bulk update, then in a loop manually trigger the signal for each…
gdvalderrama
  • 713
  • 1
  • 17
  • 26
0
votes
1 answer

What signal to listen to for new Many-To-One relations?

from django.db import models class Reporter(models.Model): pass class Article(models.Model): reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE, null=True) With the models above, what signal should I listen to if I want to…
Oskar Persson
  • 6,605
  • 15
  • 63
  • 124
0
votes
1 answer

User Profile Creation on User model's post_save signal

I have UserProfile model that I instantiate whenever a User is created by using post_save signal everything is working fine except the ImageField in the userprofile. I am using django-allauth for signup and login. When I try to access the profile…
blueChair
  • 145
  • 2
  • 13
0
votes
1 answer

Overriding save method raises exception when object is created

I'm trying to create an identificator for my Scheduler model which depends on ManyToManyField of this model. The problem is that when I override save method, the first time (when object is created) it causes problems. It should be saved first. On…
Milano
  • 18,048
  • 37
  • 153
  • 353
0
votes
0 answers

Django Signal or Callback from Mysql Events and Trigger

I have MySQL event running on every month and deletes the old records. While deleting the records I want to send the push notifications to the user. Is there any way we can define it in Django to receive the deleted records ids from Mysql to send…
Karesh A
  • 1,731
  • 3
  • 22
  • 47
0
votes
1 answer

Override model save to send request along with post_save

Problem Django models send the signal post_save when a model is saved. The post_save, however, does not have access to the request object. I need to access variables like request.user and send it with the signal. Possible solutions Admin - Override…
Ajoy
  • 1,838
  • 3
  • 30
  • 57
0
votes
1 answer

Django OneToOneField and signals

I have a model called DeviceStatus which has a OneToOne relationship with another model called Device. I want to get the id passed to the DeviceStatus object before saving, but all I get is a ForwardManyToOneDescriptor object. class…
Venu Saini
  • 427
  • 2
  • 6
  • 19
0
votes
1 answer

Django signal received not being called

I've used Django signals in the past. I'm working on a 1.10 app now, and for some reason I cannot get my receiver to be called. app1/signals.py from django.dispatch import Signal list_member_updated =…
0
votes
0 answers

Django post_save signal, created argument

I'm having trouble accessing the created argument, from my post_save signal receiver. @receiver(post_save, sender=Facility) def add_times(sender, **kwargs): instance = kwargs.get('instance', None) created = kwargs.get('created', False) …
Juddling
  • 4,594
  • 8
  • 34
  • 40
0
votes
1 answer

Signals working only in shell,not working in admin and frontend

I am trying to assign some values to a model field after post-save.The model is class Authority(models.Model): no_of_feeds=models.PositiveIntegerField() no_of_rf=models.PositiveIntegerField() …
A.Lang
  • 59
  • 1
  • 8