""" notification models file """ # django imports from django.db import models from django.contrib.auth import get_user_model from django.utils import timezone USER = get_user_model() class Notification(models.Model): """ used to save the notifications """ notification_type = models.CharField(max_length=50, blank=True, null=True) notification_to = models.ForeignKey(USER, related_name='to_notification', on_delete=models.CASCADE) notification_from = models.ForeignKey(USER, related_name='from_notification', on_delete=models.SET_NULL, blank=True, null=True) data = models.JSONField(default=dict, blank=True, null=True) is_read = models.BooleanField(default=False) created_at = models.DateTimeField(default=timezone.now) def __str__(self): """ string representation """ return f"{self.notification_to.id} | {self.notification_to.email}"