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

Python/Django: How to delete an instance automatically after an action?

I have created a Django project in which type-1 users can create a Post and type-1 users can Bid on a post. Finally, auction happens and a post_owner can accept a bid. After this whole process, I wanted to remove the post instance from the database,…
sumanth
  • 751
  • 2
  • 15
  • 34
0
votes
2 answers

How to execute code after authentication in Django?

I want to execute one or more functions after a user logs into my site. How is this possible? I looked into Middleware. Djangobook says that I'll need this to run a piece of code on each and every request that Django handles. However, I just need…
0
votes
3 answers

Deleting the m2m relationship instead of the the object itself in Django via REST API

I have 3 models: User, UserItem (the m2m thourgh), and Item. A User can create an Item. This automatically creates a UserItem. A different User can see that Item, and add it to their own list of items, creating another UserItem. If that first User…
0
votes
0 answers

Django m2m not saves in m2m_changed signal

I have a model Location with m2m relation with Place and School Each time places field is changed I want to set all existing schools to Location from django.db.models.signals import m2m_changed class Location(model.Model): places =…
MaxCore
  • 2,438
  • 4
  • 25
  • 43
0
votes
1 answer

Django Signal on method call (not triggering model instance)

We have a model: class Item(model.Model): pass def items_red(self): # filter items by red color # model instance is NOT changed (saved) pass I need to catch Item.items_red() method execution with Django signal. Any…
yanik
  • 798
  • 11
  • 33
0
votes
1 answer

No value of the instance's field when creating another object with Signal

I have an Tag model, a News model and a Activity model. A news object can have many tags. Also an activity object can have many tags. class Tag(models.Model): name = models.CharField(max_length=20, unique=True) class News(models.Model): …
Aamu
  • 3,431
  • 7
  • 39
  • 61
0
votes
1 answer

Django - admin approve order

I'm working on a project where Users can order a translations. If User creates an order, the translation object is created and message sent to translators. But I want to make admin able to approve each translation. So after creating an object…
Milano
  • 18,048
  • 37
  • 153
  • 353
0
votes
1 answer

Django : notifications refresh automatically

I created a notification system adapted to my website and it's works. When a user is on home page, he can see his notifications. But currently, for refresh his notifications the user have to reload the home page... (currently notifications visibles…
ZouIou
  • 35
  • 4
0
votes
1 answer

ValueError: needs to have a value for field "cart" before this many-to-many relationship can be used

I'm facing the problem with the following code: class Cart(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True) items = models.ManyToManyField(CC, blank=True) total = models.DecimalField(max_digits=10,…
0
votes
2 answers

Django Signal User when is registred with facebook

I am asking for how to add a Signal in model User and know if that user was registred through Facebook, I mean, if an new User is created in Django with Facebook I want to catch this event and save a new Customer model. I believe that could be…
Pablo Alejandro
  • 591
  • 2
  • 10
  • 19
0
votes
1 answer

django-need to create model object when related forigenkey model object is created

i have two model "product detail" and "status" class product_detail(models.Model): modelNO=models.CharField(max_length=50) Channels=models.CharField(max_length=50) class status(models.Model): …
masternone
  • 429
  • 5
  • 13
0
votes
1 answer

Django, Add value to ManyToManyField when save changes of the model

I use Django 1.7.11. I have models: #I use django-categories app here class Category(CategoryBase): pass class Advertisment(models.Model): title = models.CharField(max_length=255, blank=True) category = models.ForeignKey(Category,…
Swallow
  • 69
  • 1
  • 13
0
votes
1 answer

Django. Why my signal function doesn't work?

I got a model named Request with a few fields in models.py. I also got signal receiver in signals.py: @receiver(post_save, sender=Request) def status_changed(sender, **kwargs): "doing smth" But when I am trying to change some fields of Request…
0
votes
1 answer

Django signals with shopify webhooks

I am new to Django signals and Shopify webhooks, but I want to implement this feature in to a project. I am using this package, which also includes a set of WebhookSignals, to receive and verify the Shopify webhook, but then I want to do stuff with…
andreashhp
  • 485
  • 2
  • 16
0
votes
2 answers

Connect Django Models with Signals

I'm using Django 1.8. Following is my signals.py: from django.db.models.signals import post_save from django.dispatch import receiver from datetime import datetime from models import Watch, LastUpdated @receiver(post_save, sender=Watch) def…
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267