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
0 answers

Django:The value of id is coming None when adding new profile

I have the below models: class Profile(models.Model): date = models.DateTimeField(auto_now_add=True) full_name = models.CharField(max_length=32,blank=True) name = models.OneToOneField(settings.AUTH_USER_MODEL,on_delete=models.CASCADE) …
Niladry Kar
  • 1,163
  • 4
  • 20
  • 50
0
votes
1 answer

Django: How to create a signal for deleting a instance of pre_save signal?

I have the following pre_save signal in my models: @receiver(pre_save, sender=Purchase) def user_created_purchase_cgst(sender,instance,*args,**kwargs): c = Journal.objects.filter(user=instance.user, company=instance.company).count() + 1 if…
Niladry Kar
  • 1,163
  • 4
  • 20
  • 50
0
votes
1 answer

Is there a signal or anything similar to a "pre_select" in django?

I'm creating a system in django and it'd be really helpful to have a signal that is called every time a SQL "select" query is done on the database. In other words, does anyone know if there is something like a "pre_select" or "post_select" signal…
Jayme Tosi Neto
  • 1,189
  • 2
  • 19
  • 41
0
votes
1 answer

Django: How to update model instance using pre_save signal?

I want to create a pre_save signal which will update the already created model instance whenever the sender is updated. I want to do it in pre_save signal. The previous instance of the model will be either deleted and new instance will be created or…
Niladry Kar
  • 1,163
  • 4
  • 20
  • 50
0
votes
2 answers

Django signal based on the datetime field value

I'm struggling with the following. I'm trying to create a custom signal that will trigger when the current time will be equal to the value of my model's notify_on DateTimeField. Something like this: class Notification(models.Model): ... …
Nikita Tonkoskur
  • 1,440
  • 1
  • 16
  • 28
0
votes
0 answers

DJANGO Signal.disconnect - inconsistent results (really weird)

I have a custom signal and there is a classmethod which updates some objects where I need this signal to be disconnected so changes are not synced to pipedrive because this method is used only by a view for webhooks. @classmethod def…
Milano
  • 18,048
  • 37
  • 153
  • 353
0
votes
1 answer

Django AppRegistryNotReady error for signals after editing apps.py to signals

I'm using Django signals and getting a django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. The Upload model that I'm trying to import in signals.py is not loaded yet. That's why I'm getting the error. I've edited my app's app.py…
juju
  • 884
  • 1
  • 9
  • 31
0
votes
1 answer

Django not sending emails

I have a simple django application and that I can't seem to get to send emails. In my settings file I have: EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'MyHost@gmail.com' EMAIL_HOST_PASSWORD =…
0
votes
1 answer

Django - Update integer field value in one model by change in other

Here is a project I've created to practice, in my models.py, class Post(models.Model): title = models.CharField(max_length = 140) author = models.ForeignKey(User, on_delete=models.CASCADE) votes = models.BigIntegerField(default=0,…
Bidhan Majhi
  • 1,320
  • 1
  • 12
  • 25
0
votes
2 answers

Django smpt email backend slowing down performance

I'm developing/serving currently locally. I'm using django-admin for internal users to add items. I add in my signal code. My signal is post_save and it's purpose is to send an email to a user for approval. I test my signal using…
Rach Odwyer
  • 184
  • 1
  • 14
0
votes
2 answers

Setting up database replication(add/update/delete of data only) using signals in django

I do not want to use database's inbuilt features for replication. So I am trying to setup database replication(add, update, delete operation only) at djnago app level. I have configured multi-db in settings.py So setting file look like DATABASES…
Alok
  • 7,734
  • 8
  • 55
  • 100
0
votes
1 answer

signals fire up at every user login instead of post_save

I have a small signal connected to post_save of the user model. I want it to only send an email on user creation and not on login as it does in this form. I've tried with if created: but still sends email on login. from django.db.models.signals…
reiser
  • 19
  • 1
  • 5
0
votes
2 answers

How to run function if model instance field is equal to inplay (Django)

I have a model that's being updated by a background task every few seconds. I would like to execute a function when the instance of the attribute status changes to inplay I have looked through documentation and examples but can a't find what I'm…
tomoc4
  • 337
  • 2
  • 10
  • 29
0
votes
1 answer

not getting updated fields using django signals

I am trying to fetch the updated fields using django signals.when i update the model using update view and call the post_save i get the update_fields as None in the kwargs. How to get the updated fields using django signals ?? signals.py from…
beginners
  • 305
  • 3
  • 16
0
votes
1 answer

Post save signal on model takes too long

I have a model called partnershipArm, when a new model is created without the post save signal, it runs really fast. in fact when I populated the databe with just 20 members it was running fine but now I have 1168 members and it timeout everytime.…