Thursday, August 31, 2023

Re: ANYONE TO HELP ME ON HOW TO CREATE AN AUTOMATIC NOTIFICATION SYSTEM THAT SENDS A MESSAGE WHENEVER AN OBJECT IS CREATED OR MODIFIED

First of all - notification - what do you mean by notification?

If you mean that the user should be notified in the instance when someone creates / updates / deletes your models - you will need to have either server side events or websockets to communicate with the frontend. You could also poll the server (for example every 5 minutes) to check for new messages. These solutions would require that you have some javascript on the frontend.

To get this working on the backend - you would then need some sort of changes in the save method to send the notifications to the frontend. This could be as simple as creating a Notification model and then just creating a notification every time you update a model.

Regards,

Andréas


Den tis 22 aug. 2023 kl 16:02 skrev Byansi Samuel <samuelbyansi87@gmail.com>:

My views
from django.shortcuts import render def auto_notification(request): return render (request, "user/dashboard.html")

My models
from django.db import models from django.contrib.auth.models import User

#articles model

class Articles(models.Model):
title = models.CharField(max_length=300) date= models.DateField() author=models.ForeignKey(User, on_delete=models.CASCADE) body=models.TextField()

def __str__(self) -> str:
return self.title

#games model

GAME_TYPE=( ("action", "action"), ("adventure", "adventure"), ("racing", "racing"), ("puzzle", "puzzle"), )

MOV_TYPE=( ("action", "action"), ("adventure", "adventure"), ("sci-fi", "sci-fi"), ("horror", "horror"), ("drama", "drama"), )

GAME_OS=( ("Windows", "Windows"), ("Android", "Android"), )

class Games(models.Model): name=models.CharField(max_length=50) type=models.CharField(max_length=40, choices=GAME_TYPE) os=models.CharField(max_length=15, choices=GAME_OS) img=models.ImageField() developer=models.CharField(max_length=50) version=models.CharField(max_length=10) ratings=models.CharField(max_length=10) description=models.TextField()

def __str__(self) -> str:
return self.name class

Movies(models.Model): name=models.CharField(max_length=50) type=models.CharField(max_length=40, choices=MOV_TYPE) description=models.TextField() released=models.DateField()

def __str__(self) -> str:
return self.name

I have three models below, but l like to create a Notification System to send a message to a User whenever ;
1. An object is created in all those models
2. An object is modified in all those models

And l would like to add trick that it sends the Notification Message after 15 minutes of publiction or creation.

And I would like to pass the following data if available in the object ;
1. the Name of the Object,
2. the Image of the Object, and
3. the type of the Object.

Lastly I would like to add a :
1. Notification DELETE function, that gives User a way to delete that Message , not to appear in his or notification section again.

2. Mark as Read function, that changes the Massage Div Color

3. A notification Barge that displays the UNREAD Messages.

Am requesting anyone to help me Because Am stuck , I have no where to Start from. I will be on waiting your guidelines.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGQoQ3wRpg%2BcT69wqUbapHbK7KSEfwU%2BxfJ-EKRCcddY6KwtnA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdBb5kP_eF4_CK4F%2B3ibP_PvmgJetrGJs4a7PBZfxSYGg%40mail.gmail.com.

No comments:

Post a Comment