Notification system [closed]

1

I have the following template:

from django.db import models
from django.utils.timezone import now

# Create your models here.
class Event(models.Model):
    name = models.CharField('nombre',max_length = 255)
    place = models.CharField('lugar',max_length = 255)
    thematic = models.CharField('tema',max_length = 100)
    title_of_the_paper = models.CharField('tema abordado',max_length = 60)
    date_event  = models.DateField('realizado el', auto_now_add=False)
    author = models.ForeignKey(
        'professor.Professor', related_name='eventos', on_delete=models.CASCADE)

    class Meta:
        verbose_name = 'evento'
        verbose_name_plural = 'eventos'
        db_table = 'event'

I want to implement a notification system, which when a user inserts an event that notifies me to all other users about the created event. What packet should I use as I can modify the view?

This is the view

def ajax_create_event(request):
    event_form = EventForm()
    if request.method == 'POST':
        name = request.POST['name']
        place = request.POST['place']
        thematic = request.POST['thematic']
        title_of_the_paper = request.POST['title_of_the_paper']
        date_event = request.POST['date_event']
        author = request.user.teacher_profile
        form = EventForm(request.POST, request.FILES)
        if form.is_valid():
            Event.objects.create(
                name=name, place=place, thematic=thematic,title_of_the_paper = title_of_the_paper,date_event = date_event, author=author
            )
            events = Event.objects.filter(author=author)
            data = {
                'msg': 'El evento se ha guardado satisfactoriamente',
                'page': render_to_string('event/list.html', {'events': events}, request=request),
                'header': render_to_string('event/dinamic_event.html', request=request),
                'event': request.user.teacher_profile.number_of_events
            }
        return JsonResponse(data)
    else:
        data = {
            'page': render_to_string('event/add.html', {'form': event_form}, request=request)
        }
    return JsonResponse(data)
    
asked by anonymous 04.10.2018 / 03:22

1 answer

0
Django already allows you to do this by implementing Signals which is nothing more than an implementation of design pattern Observer which allows you at certain times as before saving, when saving or deleting an object let me know if you are interested in this particular event, I suggest you take a look at Signals that will resolve your problem.

    
04.10.2018 / 04:55