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

How to override a signal in the sites framework django framework

I have a model that is firing a post_save signal in the django framework set to run more than one site. What I need to do is to be able to override that signal with a signal that will be defined in the specific site that needs this signal and use…
0
votes
1 answer

Signals do not work after registering

So far I have signals.py with following content: from django.db.models.signals import post_delete, post_save from django.core.signals import request_finished from django.dispatch import receiver from students.models import…
micgeronimo
  • 2,069
  • 5
  • 23
  • 44
0
votes
1 answer

Django signals for login and registration

I need to check information in user and request models while user logging in, so I've wrote this code using django signals: from django.contrib.auth.signals import user_logged_in def on_login(sender, user, request, **kwargs): …
ip0000h
  • 158
  • 2
  • 12
0
votes
1 answer

Knowing if a foreign key is selected or not selected

class Foo(models.Model): name = models.CharField(max_length=256) total = models.SmallIntegerField() availability = models.SmallIntegerField() class Bar(models.Model): somthing = ... foo = models.ForeignKey(Foo, blank=True,…
Harry
  • 13,091
  • 29
  • 107
  • 167
0
votes
2 answers

How to detect when my Django object's DataTimeField reach current time

I'm using Django 1.5.5. Say I have an object as such: class Encounter(model.Models): date = models.DateTimeField(blank=True, null=True) How can I detect when a given Encounter has reached current time ? I don't see how signals can help me.
Mathieu Marques
  • 1,678
  • 15
  • 33
0
votes
0 answers

Django: over ride model's delete() or use signals?

I have the need to change the function of delete - I need to confirm the object has no FK connections and if it does, to deny the delete request. In the relevant Django documentation it is suggested that the pre- and post-delete signals be used…
datakid
  • 2,293
  • 5
  • 23
  • 35
0
votes
1 answer

Django signals cancel actions

I implemented Django signals to handle some actions after login, but I'd also like to be able to cancel the login actions: I have this: @receiver(user_logged_in) def my_signal(sender, **kwargs): request, user = kwargs['request'], kwargs['user'] …
Andres
  • 4,323
  • 7
  • 39
  • 53
0
votes
1 answer

Receiving duplicate signals. How to search for the cause?

I have a wrote a Django signal in the __init__.py of my project. looks like this: from django.db.models.signals import post_save from paypal.standard.ipn.models import PayPalIPN def confirm_paypal_payment(sender, **kwargs): obj =…
André
  • 24,706
  • 43
  • 121
  • 178
0
votes
1 answer

Django Comments Signals firing twice

I've attached a handler to the django.contrib.comments signals (comment_was_posted and comment_will_be_posted). Each handler is being called twice. I can't seem to figure out why, nor can I figure out how to tell if I'm on the first or second call.…
dubloons
  • 1,136
  • 2
  • 12
  • 25
0
votes
2 answers

Post_save signal implementation in Django

I have models like this: class Devices(models.Model): name = models.CharField(max_length=255, blank=True) uniqueid = models.CharField(db_column='uniqueid'.lower(), max_length=255, blank=True) # Field name made lowercase. …
pynovice
  • 7,424
  • 25
  • 69
  • 109
0
votes
2 answers

Django - using django-registration app with signals

Ok, so I've built a basic Django Project and successfuly installed the django-registration app - http://www.michelepasin.org/blog/2011/01/14/setting-up-django-registration/ I want to expand a User to include information like Birthday, Profile…
Mihai Zamfir
  • 2,167
  • 4
  • 22
  • 37
0
votes
0 answers

Get notification when there's new update/insert in the database

I have setup most of the part for an instagram like app, including the django-signals too. What I need is, whenever a user comments, or posts a new photo, I want it to notify the users without refreshing the page, like when Twitter, Stack Overflow…
Robin
  • 5,366
  • 17
  • 57
  • 87
0
votes
2 answers

Django connect temporary pre_save signal

I've been struggling with a Django signal issue for a few days now and would appreciate your thoughts. Scenario: I wish to use a black box method (it's actually the LayerMapping loader in geodjango, but that's not important here) that generates and…
Gabriel
  • 1,870
  • 1
  • 19
  • 20
0
votes
1 answer

How to Implement django - pre_save and post_save?

I have tried much to implement django's pre_save and post_save, but still I am unable to generate the signal. What I have is: Class Client(models.Model): . . . # some fields Class ClientView(models.Model): . . . # some…
MHS
  • 2,260
  • 11
  • 31
  • 45
0
votes
2 answers

post_save signal: Creating Extended User Profile, Where to put

I want to extend my User by creating a UserProfile object. I'm following this example: Creating a extended user profile Silly question, but ...errr... where is this file supposed to reside / be called so every time the user is created, this…
KingFish
  • 8,773
  • 12
  • 53
  • 81