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

Stop signal send trigger for specific Sender

I'm using Django 2.2 In my application, there is a shared user feature and every shared user are added to User model with is_shared field set to True. The shared user is linked to a user in SharedUser model like class SharedUser(models.Model) …
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
0
votes
1 answer

How to get the user from a manytomanyfield in Django using Django singals and creating another object with the recived manytomany user field

I want to know is there any way where we can get the updated many to many field in one model using signals and post them to another model class Post(models.Model): name=models.CharField(max_length=24) …
john
  • 539
  • 2
  • 9
  • 24
0
votes
0 answers

Large transfer of data between several Django models

I have 6 models, three of 2 types. The types being private and public, but, in this case, all the models have the same fields. class AbstractModel(models.Model): text = models.CharField(max_length = 1) in_group =…
user10973829
0
votes
0 answers

How to run the post_save signal after a specified time?

There is a post_save signal. Need to run it no earlier than an hour after the creation of the object. I can use time.sleep(3600), but this is not the best approach, as I understand it. What other options are there?
user11301070
0
votes
1 answer

Distinguish which field has changed in signal.instance , Django/signals

Lets say I have a model called BookModel with 4 fields : (title, author, price, publish_year). And I have a handler in signals: @receiver([post_save, post_delete], sender=BookModel) def signal_handler(sender, instance, **kwargs): ….. Question is…
Aleksei Khatkevich
  • 1,923
  • 2
  • 10
  • 27
0
votes
1 answer

Django: Post-Save Signal TransactionManagementError

I am using post-save signal for a model to start a celery task. It was working before but suddenly, it is giving me a TransactionManagementError. Model class FieldSightXF(models.Model): xf = models.ForeignKey(XForm,…
Sanip
  • 1,772
  • 1
  • 14
  • 29
0
votes
1 answer

How to check which user triggered a signal?

I have a simple signal in my project, that checks which fields have been updated in the form. I also need to check the user who changed data in those fields. Request.user doesn't seem to work here. @receiver(sender=BackOperator,…
ZmuA
  • 151
  • 1
  • 13
0
votes
0 answers

Django CRUD : Reload object after CRUD update

I'm working on a dynamical object menu in my project (with django-simple-menu) and I have some questions in order to display this one after updated it. Especially reload the menu immediately after the update to display changes. I have a simple…
ChocoBomb
  • 301
  • 4
  • 15
0
votes
1 answer

How to make sum query with type casting and calculation in django views?

I'm calculating the sold items cost in django views and in django signals, and I want to calculate sold items cost on the fly. Price and quantity fields are integers. How can I convert one of them to the float and make sum query with some…
0
votes
1 answer

Django_auth_ldap: User from LDAP post_save signal 'created' flag always false

I am trying to allow LDAP users to login to my Django application. Each user needs some additional attributes which I want to store in a User Profile model. I have implemented the 'post_save' signal to create the userprofile on initial login,…
0
votes
1 answer

how to group different model updates when listening to post_save in changes

I have a bunch of models in my app for which I am listening to changes with post_save. Additionally I have an updated_at field on all of those which is a timestamp that will be updated on every save operation. Assuming a model Question with a one…
matteok
  • 2,189
  • 3
  • 30
  • 54
0
votes
1 answer

Why else block is executing while if block is true in Django signals?

I am writing a signal function that will send a signup notification email to the user when s/he signs up and an update notification email when s/he updates the user profile. For that, I have used an if-else block to check the created parameter. If…
0
votes
1 answer

Sending model updates from db to clients with WSGI

What is the most lightweight way to notify clients of changes to a model table they are viewing? I've used Django Rest Framework to set up an API that serves a templated table of items to clients, and allows them to change buyers on the…
0
votes
2 answers

Saving model instance using pre_save signal

These are my models: class Stockdata(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,null=True,blank=True,related_name='user_stock') company =…
Niladry Kar
  • 1,163
  • 4
  • 20
  • 50
0
votes
0 answers

Django signal gets triggered before file is saved in server?

I am learning how to work with Django signals and celery tasks. So, I am uploading a bulk csv file to the server and my goal is to read the contents of the file once it is uploaded. Now, this is the approach I used, once the Fileupload object is…
Anastacia
  • 33
  • 2
  • 5