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 implementing subscribers

I have a very simple web application. A student comes in and he creates a note in one of the subjects. Each subject has number of subscribers. Similar to stackoverflow tags, once a tag has been added to a question, the subscribers are notified.…
user1629366
  • 1,931
  • 5
  • 20
  • 30
0
votes
2 answers

Issue using fixtures in tests with Django DirtyFields

Is there a known issue when using fixtures in tests if you are implementing Django DirtyFields? We use django_nose's NoseTestSuiteRunner with fixtures and coverage. I was going to try implementing django-dirtyfields to do some custom post_save()…
Rico
  • 5,692
  • 8
  • 46
  • 63
0
votes
2 answers

writing django signal hook to check whether user already exists

We recently switched from one LDAP system to another. Unfortunately, not only the LDAP server changed but all usernames did too. I managed to configure django_auth_ldap to deal with two LDAP servers, however I can not prevent the creation of new…
memyself
  • 11,907
  • 14
  • 61
  • 102
0
votes
2 answers

Django send signal sometime in the future

I have a model that takes an expires_at time field. In the sense, the user can set a time beyond which the entry is invalid. At that time, I need to do specific actions such as send email and/or change a parameter in the model. Specifically, say I…
Sidd
  • 1,168
  • 2
  • 10
  • 27
0
votes
1 answer

Django receiver Column 'user_id' cannot be null

I'm using userena receiver but I'm getting the following error... IntegrityError at /accounts/signup/ (1048, "Column 'user_id' cannot be null") I'm assuming that I'm not accessing the user correctly in my own receivers.py. Could someone take a…
MarkO
  • 775
  • 2
  • 12
  • 25
0
votes
1 answer

post_save error Message' has no attribute

I'm trying to use signals post_save for the first time. I have read the documents, but still need some advice. I'm trying to update my model field called 'charge'. @receiver(post_save, sender=Message) def my_handler(sender, **kwargs): if not…
MarkO
  • 775
  • 2
  • 12
  • 25
0
votes
1 answer

To use signals or override model save method?

Simple use case: After a user updates a record, I want to get the changed fields and save them in a history table. I'm using django-ditryfields to grab this history. So my thought process was to use the pre_save signal to grab all the 'dirty' fields…
Austin
  • 4,296
  • 6
  • 40
  • 52
0
votes
1 answer

Having access to a model function on every request for a user

I have a model called Account, with has a model function (see code below). I would like to show in my template the users total on every page. The only way I can think of doing this in putting accounts in every view. What other options do I have? Can…
MarkO
  • 775
  • 2
  • 12
  • 25
0
votes
1 answer

Using signals concept to do events

This is i am doing to send mail once a record is updated in the database.I had defined the receivers in separate file called listeners.py to receive the signals. signals.py import django.dispatch send_email_to =…
user2086641
  • 4,331
  • 13
  • 56
  • 96
0
votes
2 answers

Django database watchdog save signal outside django

I have the following problem: I Am using a Django framework. One of the parts in a system (non-django) writes to the database, in the same database that django is using. I want to have a signal when an object is being saved. It's a django model…
michel.iamit
  • 5,788
  • 9
  • 55
  • 74
0
votes
1 answer

Warehousing records from a flat item table: Django Signals or PostgreSQL Triggers?

I have a Django website with a PostgreSQL database. There is a Django app and model for a 'flat' item table with many records being inserted regularly, up to millions of inserts per month. I would like to use these records to automatically populate…
Sectio Aurea
  • 393
  • 6
  • 10
0
votes
1 answer

Using m2m_changed signal

first some information about the app: I want to be able to upload a pdf file, that pdf file will be converted to images (for every pdf page one image). These images will then be shown on the website and the pdf can be downloaded: So far I have…
wagner-felix
  • 855
  • 3
  • 9
  • 19
0
votes
1 answer

m2m_changed not trigger for custom "through" model

I have a custom through intermediary model for ManyToManyField between Wishlist and Product: class Product(models.Model): name = models.CharField(max_length=255) created = models.DateTimeField(auto_now_add=True) class Meta: …
Vinta
  • 387
  • 4
  • 10
0
votes
1 answer

Django - many to many with post_save gridlock

I want to send out an email when a model instance is saved. To do this I listen out for the post_save signal: #models.py @receiver(post_save, sender=MyModel, dispatch_uid="something") def send_email(sender, **kwargs): instance =…
powlo
  • 2,538
  • 3
  • 28
  • 38
0
votes
1 answer

Model instance retrieved from signal does not work as expected

Here is code from my models.py #Models.py .... class Question(models.Model): text = models.TextField(unique=True) exam = models.ForeignKey(Exam) level = models.ForeignKey(Level) paper = models.ForeignKey(Paper) topic =…
Tundebabzy
  • 829
  • 2
  • 11
  • 24