Notification system

0

I have this model:

and I want the system whenever a user creates an event that notifies the other users, the event created and the name of the user who created it.

I do not see how to start implementing, I am using the version of python 3.6.0 and the Django-2.0.5.

Thanks

    
asked by edivaldo machado 04.10.2018 в 04:08
source

1 answer

0

I recommend you start by installing django-notifications . This is what I usually use for this type of tasks and allows you to abstract the subject of notifications of any model you want to associate it with.

Once installed, just use signals so that when there are modifications or creations of Event you create the relevant notification. For example:

# signals.py
...

@receiver(post_save, sender=models.Event)
def notify_event(sender, instance, created, **kwargs):
    if created:
        notify.send(instance.author,
                    recipient=recipient,
                    verb='ha creado un evento',
                    target=instance)

For more information regarding signals , you can take a look here .

    
answered by 09.10.2018 в 10:46