20 lines
696 B
Python
20 lines
696 B
Python
import uuid
|
|
from django.conf import settings
|
|
from django.db import models
|
|
|
|
|
|
class Notification(models.Model):
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="notifications")
|
|
type = models.CharField(max_length=50, blank=True)
|
|
title = models.CharField(max_length=255)
|
|
message = models.TextField()
|
|
is_read = models.BooleanField(default=False)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
db_table = "notifications"
|
|
ordering = ["-created_at"]
|
|
|
|
def __str__(self):
|
|
return f"Notification: {self.title}"
|