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

Viewflow - start process with Django model post_save signal

Is there a way to start a Viewflow process with Django model post_save signal. I managed to do this: //start viewflow process start = ( flow.StartSignal(post_save, create_dest_flow) .Next(this.approve) ) //create flow function def…
Silko
  • 584
  • 1
  • 8
  • 26
0
votes
1 answer

Create a signal for when a model is created

I have checked django docs on built in signals for this (https://docs.djangoproject.com/en/2.1/ref/signals).I have 2 models: Member and Tithe. Every member has a tithe record, I want a tithe record to be created whenever a member is created.This is…
0
votes
1 answer

Changing pre_save signal into post_save?Django

This are my models: class Purchase(models.Model): Total_Purchase = models.DecimalField(max_digits=10,decimal_places=2,blank=True, null=True) class Stock_Total(models.Model): purchases =…
Niladry Kar
  • 1,163
  • 4
  • 20
  • 50
0
votes
0 answers

push live updates to client through Django Channels & Websockets when database get updated

I am very new to django channels.I wan't to try out. using django channels, If I added one user through django admin portal then this will be update on live on page where i am displaying users list. Using django post-save is this possible Please…
0
votes
1 answer

How can i check if model field was changed in post_save?

I have to do some extra logic in post_save if one of model fields was updated, but can't check if it was updated. Tried to override init method like this def __init__(self, *args, **kwargs): super(Profile, self).__init__(*args, **kwargs) …
George
  • 37
  • 9
0
votes
1 answer

Django autocategorize in m2m field

I have done a pre_save signal in my django/satchmo inherited model Product called JPiece and I have another model inheritance from satchmo Category called JewelCategory. The pre_save signal makes the JPiece objects get the category list and add…
maumercado
  • 1,453
  • 4
  • 23
  • 47
0
votes
1 answer

What are the typical use cases for pre-save, post-save, pre-delete, post-delete signals in Django?

Could not find much in the docs here regarding use cases. However, I assume something along these lines: Pre-Save: Used for calculated fields, example, we might want to calculate the age from date of birth and save that in the database. Post-Save:…
darkhorse
  • 8,192
  • 21
  • 72
  • 148
0
votes
0 answers

Django post save signal calling two times with each request

I'm using Django 2.x I have a model TransactionLog which logs the amount given and updated. Each time amount is given, a new record is created in AmountGiven model and thus will create a log with action as given and if the earlier given amount is…
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
0
votes
0 answers

Paypal IPN notify_url not called in django project

Everything is working apart from notify url receiver call back is not working Following are the codes in my views.py def view_that_asks_for_money(request): # generating invoice id total_invoices = 0 invoices_of_user =…
0
votes
0 answers

Django signals - multiple requests on same model?

I am using a pre_save signal to store the user who performed the last operation on a particular instance. To achieve this, I'm using a middleware. In the process_request function of it, the signal is registered with the appropriate function,…
0
votes
0 answers

Django Signals - "Created" argument becomes false

I am working on an ECommerce website, I use signals to update the total value in the 'Order'. -> post_save_cart_total() - is called whenever a new cart is created -> post_save_order() - is called whenever an order is created or changed in the…
0
votes
1 answer

Can I perform queries in django pre_save signals?

This is models.py class ledger1(models.Model): User = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,null=True,blank=True) Company =…
Niladry Kar
  • 1,163
  • 4
  • 20
  • 50
0
votes
0 answers

How to disable Django signals in View?

I'm writing a migration script and I don't want the signals to be triggered. How do I disconnect signal from views? View.py pre_save.disconnect( pre_save_callback, sender=MyModel) Error: NameError: name 'pre_save_callback' is not defined signal…
Wreeecks
  • 2,186
  • 1
  • 33
  • 53
0
votes
3 answers

Using AppConfig to import signals is not working Django 2.08

I have an app companies. Inside the app there is a file called signals.py with the following code: post_save.connect(update_descendants, sender=Company) Inside companies apps.py I have: class CompaniesConfig(AppConfig): name =…
J Mo
  • 43
  • 6
0
votes
1 answer

Django add to cart and cart view error

I get a 'NoneType' object is not iterable error when I add 1 object to the cart via the scan_to_cart view and want to add a second object. Also I get the same error when I want to view my cart when there are actually objects in it. I could not find…
sandermander
  • 73
  • 11