base setup
This commit is contained in:
22
at_django_boilerplate/notification/models.py
Executable file
22
at_django_boilerplate/notification/models.py
Executable file
@@ -0,0 +1,22 @@
|
||||
# notifications_app/models.py
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
|
||||
class Notification(models.Model):
|
||||
recipient = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="notifications"
|
||||
)
|
||||
message = models.TextField()
|
||||
is_read = models.BooleanField(default=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
is_archived = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-created_at"]
|
||||
|
||||
def __str__(self):
|
||||
return f"To {self.recipient} - {self.message[:30]}"
|
||||
|
||||
def soft_delete(self):
|
||||
self.is_archived = True
|
||||
self.save()
|
||||
Reference in New Issue
Block a user