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

Updating Notification model in django using signals

I'm working on a books inventory project. I'm trying to send notification to user as soon as a new book is added. I've built this notification model: ... class Notification(models.Model): title =models.CharField(max_length =255) message…
jitesh2796
  • 164
  • 6
  • 14
0
votes
0 answers

How can I make my signals work and resolve this problem?

Hi I'm trying to develop a website for an online store and I don't know why, for some reason, my models.py and signals.py are not coming into affect. When I ran the makemigrations command, it was ok, but when I ran the migrate command, it said "No…
user13080604
0
votes
1 answer

Django signals default data working for one child but not for many

I have a signals file that I would like to be run every time a child is created. For some reason, it has created the default information for one child but if another one is added, it does not create the default information. Does not work for other…
0
votes
1 answer

How to auto update data in django?

I am trying to build eCommerce application in Django. In each product I have three label tags which are is_new, is_hot, is_promo. is_new will be True when a product will create, I have done it. But the system needs to automatically make is_new to…
0
votes
1 answer

Django Signals - How to save the instance

I am using Django Rest Framework to upload videos. Now I wanted to add thumbnails to my video files. Whenever a Video object is saved, I wanted to create a thumbnail and set its thumbnail field. My Video model looks like this: class…
0
votes
1 answer

Django signals not working inspite of putting everything in place

My Case In my case User is the default django user model and I've created a Profile to add more details to the User model. To achieve Now what i want is that whenever I create a new User a Profile for that user should automatically get created. I've…
Apoorv pandey
  • 509
  • 8
  • 21
0
votes
2 answers

Should I use django Signals in this case?

I’m a beginner, I discover many things and sometimes I feel overwhelmed about all the informations and tricks to learn. I try to do a django project for a pizzeria. People can order pizza online, the order is simple : you can choose one or more…
Sassem
  • 3
  • 3
0
votes
1 answer

Can't send signals to the user

enter image description herei'm sending notifications to a user via django notifications.. and i have username regex working on the html so anyone posts with @username it wil post and the html is linkable so click on the @username it will take hie…
0
votes
1 answer

Django signals post_save update

When the student enrollment record (discount type) is updated the student discount (discount type) is also updated, but what should i do if i want to update the student enrollment record (discount type) using student discount (discount type) This is…
user12290120
0
votes
1 answer

Django admin try catch on signals

Hi I'm currently having trouble to skip not show error(admin side) when doing a query in Django signal function I have these two model: class TopUp(models.Model): class Meta: db_table = "topups" verbose_name = 'Topup' …
Linh Nguyen
  • 3,452
  • 4
  • 23
  • 67
0
votes
1 answer

Django signal to follow/unfollow

I have a signal that looks like this: @receiver([post_save, post_delete], sender=Following) def increment_follow_count(instance, created=False, **kwargs): if created: instance.follower.following_count += 1 …
user2896120
  • 3,180
  • 4
  • 40
  • 100
0
votes
0 answers

How can I send userid from form request to pre_ or post_delete signal?

Another question form novice. I have some form: class SomeForm(forms.ModelForm): ... def save(self, commit=False): instance = SomeModel(field='value1') instance.userid = self.request.user.id instance.delete() instance =…
0
votes
1 answer

catch the return values of overridden save function in custom function written for post_save in django

I am implementing a notification system in my django application for which i am using signals (post_save). I am recording the changes in overridden save method of the model and returning it. My query is that how can i catch it in function written…
Kundan
  • 21
  • 2
0
votes
0 answers

How to create multiple objects of same model by triggering django post_save signal

I'm trying to create 52 objects of this model, (each corresponding 52 weeks of the year): from django.db.models import OneToOneField, TextField, IntegerField, Model, CASCADE from main_app.models import Master class WeeklyMemo(Model): master =…
Kiran Racherla
  • 219
  • 3
  • 12
0
votes
1 answer

django post_save causing IntegrityError - duplicate entry

I need help to fix the issue IntegrityError at /admin/gp/schprograms/add/ (1062, "Duplicate entry '65' for key 'PRIMARY'") I am trying to insert a row into a table SchProgramForStates (whenever new entry gets added into a model SchPrograms) with…
Raju Singh
  • 455
  • 1
  • 6
  • 15