I'm a beginner's level Django developer and I'm making a hospital system. In the hospital system, I want to add a notification system whenever any patient uploads a report against the doctor id I want to inform the doctor to the doctor notifications template that the report of patient(with name) has been submitted.
I was trying it to work for 2 days and used signals to create a message but I'm unable to show it on the doctor's side. Please anyone can tell me how can I make it easier or Should I use something else instead of signals.
The Previous Code that I tried.
from django.shortcuts import render, HttpResponse,request
from hospital.models import Patient ,Doctor,Report
from django.db.models.signals import post_save,pre_save
def save_report(sender,instance,**kwargs):
instance = Patient.objects.get(id=1)
dr_id= instance.assignedDoctorId
patient=models.Patient.objects.get(user_id=request.user.id)
doctor=models.Doctor.objects.get(id=dr_id)
notifications=print("New report has been submitted")
mydict={
'doctor':doctor,
'patient':patient,
'notifications':notifications
}
return render(request,'temp/doctor_Notifications.html',context=mydict)
post_save.connect(save_report,sender=Report)