Add: new model to handel multiple versions of the title

This commit is contained in:
Aroy-Art 2025-03-18 13:49:55 +01:00
parent b05ad89842
commit f3d67d8f97
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -37,6 +37,34 @@ class CategoryModel(models.Model):
return str(self.slug)
class TitleModel(models.Model):
hash = models.CharField(max_length=128)
content = models.TextField()
date_modified = models.DateTimeField(auto_now=True, editable=True)
date_created = models.DateTimeField(auto_now_add=True, editable=True)
class Meta:
verbose_name = "Title"
verbose_name_plural = "Titles"
def __str__(self):
return str(self.hash)
class PostTitle(models.Model):
post = models.ForeignKey("PostModel", on_delete=models.CASCADE)
title = models.ForeignKey(TitleModel, on_delete=models.CASCADE)
# order = models.IntegerField()
date_imported = models.DateTimeField(auto_now_add=True)
class CreatorTitle(models.Model):
creator = models.ForeignKey("CreatorModel", on_delete=models.CASCADE)
title = models.ForeignKey(TitleModel, on_delete=models.CASCADE)
# order = models.IntegerField()
date_imported = models.DateTimeField(auto_now_add=True)
class DescriptionModel(models.Model):
hash = models.CharField(max_length=128)
content = models.TextField()
@ -122,7 +150,9 @@ class TagModel(models.Model):
class PostModel(models.Model):
post_id = models.CharField(max_length=128, db_index=True)
title = models.CharField(max_length=64)
title = models.ManyToManyField(
to=TitleModel, related_name="posts", through=PostTitle
)
description = models.ManyToManyField(
to=DescriptionModel, related_name="posts", through=PostDescription
)