gestiojeux/comments/models.py
sinavir fee31ab07b feat: switch to authens
Be careful there is no User migration
2024-07-04 18:15:57 +02:00

24 lines
735 B
Python

from django.contrib.auth.models import User
from django.db import models
class AbstractComment(models.Model):
commented_object = None # Fill this with a foreign key in subclasses
author = models.ForeignKey(
User, on_delete=models.CASCADE, verbose_name="auteur·ice"
)
text = models.TextField(verbose_name="texte")
created_on = models.DateTimeField(
auto_now_add=True, verbose_name="date de publication"
)
modified_on = models.DateTimeField(
auto_now=True, verbose_name="date de modification"
)
class Meta:
abstract = True
ordering = ["created_on"]
def __str__(self):
return "({}) {}: {}".format(self.commented_object, self.author, self.text)