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

How to tell django not to save an instance in database?

I have written this signal receiver in django 1.6 that is intended to block posted comments containing bad words from being saved database: @receiver(pre_save, sender= Comment) def spam_filter(sender, **kwargs): cmnt = kwargs['instance'] …
supermario
  • 2,625
  • 4
  • 38
  • 58
0
votes
1 answer

How do I adjust the template context given the request object via receiver?

I have a signal named user_logged_in that is dispatched when the user logs in. When the signal is received by post_user_logged_in and the user has a session variable named do_stuff set, I want to run do_stuff(), delete the session variable, and then…
Hakan B.
  • 2,319
  • 23
  • 29
0
votes
1 answer

Add Django Variables in Email Template

I have a relatively simple objective: send email to Django admins when users register and activate their accounts that contain user information, like username, email, etc. I am using django-registration for handling the registration process. I then…
nicorellius
  • 3,715
  • 4
  • 48
  • 79
0
votes
2 answers

Django allauth && UserProfile creation with post_save

I' m using django-allauth to authenticate users from different social sites. When a User is created in my db, i' d like to call a function which would create a UserProfile (or would do something) and to achieve this the best would be to use…
user2194805
  • 1,201
  • 1
  • 17
  • 35
0
votes
1 answer

Updating an object fires post_save signal

I have post_save signal set up so that every time a new object gets saved the signal is fired. The problem is this signal is getting fired even when an existing object is updated. Im updating the object with save() as it says in the django docs but…
user3030969
  • 1,505
  • 2
  • 15
  • 17
0
votes
1 answer

Django: m2m relationship is not getting updated in post_save signal

In my problem, the m2m relationship is not getting updated in post_save signal. I have a post_save that checks to make sure that the user is a staff member and if they don't have default permissions, then they are assigned default permissions. If…
jackiekazil
  • 5,696
  • 4
  • 21
  • 20
0
votes
1 answer

Django custom user, how to get signals to work in 1.5

I'm using Django 1.5, which allows custom users. I already got the custom users to work on its own. I'd like to add a new model Blah whenever a custom user is created (aka use signals to do this). currently, I have in signals.py from group.models…
jdang634
  • 75
  • 5
0
votes
1 answer

django-signal instance to email sending attribute encoding

Good day. The model with signal must send to email instance, but i've got traceback which i place after codeblock class ParticipantModel(models.Model): TYPE_USER = ( ('O', 'Онлайн трансляция'), ('P', 'Персональное присутствие'), ) name =…
0
votes
1 answer

django-signals don't send me notification

i have next model with signal : class ParticipantModel(models.Model): TYPE_USER = ( ('O', 'Онлайн трансляция'), ('P', 'Персональное присутствие'), ) name = models.CharField( max_length=256, verbose_name='Имя') …
0
votes
1 answer

Django Assign-perm w/ Post-Save Signal

I have a django model named archive that is tied to a group (django auth) by a foreign key. In order for a user to edit something in this archive, they must have permission to do so through django-guardian. I can link an archive with a group as…
mh00h
  • 1,824
  • 3
  • 25
  • 45
0
votes
1 answer

Django - User pre_save seems called after validation

I need to generate a username if none is given when creating or updating a user. I though about using a pre_save signal @receiver(pre_save, sender=User, dispatch_uid='autocreate_username') def create_username(sender, instance, **kwargs): if…
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
0
votes
0 answers

Custom Django signal receiver getting data

I'm very new to programming and especially to Django but can't work out how to use any previous answers to my advantage.... Apologies if my question is too vague but essentially, I have two different apps, let's call them app A and app B, with data…
user2564502
  • 937
  • 2
  • 10
  • 16
0
votes
1 answer

Django: how to execute code ONLY after the first time a M2M relationship is added?

I'm trying to get create_reminder_send_message() executed THE FIRST TIME the Reminder object is saved AND the Reminder.users is saved. The code as it is executes every time I update the object... what am I missing? How can I accomplish what I…
la_f0ka
  • 1,773
  • 3
  • 23
  • 44
0
votes
1 answer

django: connecting to existing signal fails

I started using django_openid_auth (https://launchpad.net/django-openid-auth) and it works just fine. I manage to connect to my openid provider and get user authenticated. Thing is that in django_open_auth.views.login_complete there is this…
Odif Yltsaeb
  • 5,575
  • 12
  • 49
  • 80
0
votes
1 answer

Signal m2m_changed never triggered

class Lab(Model): pass class School(Model): labs = ManyToManyField(Lab, related_name='schools') def m2m_changed_labs(*args, **kwargs): pass m2m_changed.connect(m2m_changed_labs, sender=Lab.schools) The m2m_changed signal is never…
user2282405
  • 873
  • 2
  • 9
  • 10