diff options
Diffstat (limited to 'app/jrnl/models.py')
-rw-r--r-- | app/jrnl/models.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py index 88fd84b..a88e79a 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -3,6 +3,8 @@ import os from django.dispatch import receiver from django.contrib.gis.db import models +from django.contrib.contenttypes.fields import GenericRelation, GenericForeignKey +from django.contrib.contenttypes.models import ContentType from django.urls import reverse from django.utils.functional import cached_property from django.apps import apps @@ -35,6 +37,14 @@ def image_url_replace(s): return s +class RelatedPost(models.Model): + post_model = models.ForeignKey(ContentType, null=True, on_delete=models.SET_NULL) + slug = models.SlugField() + + def __str__(self): + return self.slug + + class Entry(models.Model): title = models.CharField(max_length=200) subtitle = models.CharField(max_length=200, blank=True) @@ -67,6 +77,7 @@ class Entry(models.Model): has_video = models.BooleanField(blank=True, default=False) field_notes = models.ManyToManyField(FieldNote, blank=True) books = models.ManyToManyField(Book, blank=True) + related = models.ManyToManyField(RelatedPost, blank=True) class Meta: ordering = ('-pub_date',) |