Add: new model to handel multiple versions of the title
This commit is contained in:
parent
b05ad89842
commit
f3d67d8f97
1 changed files with 31 additions and 1 deletions
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue