From 51aae2ec53dc679eca2fac6c08c18da2e357becc Mon Sep 17 00:00:00 2001 From: j Date: Tue, 19 Dec 2017 11:54:06 +0100 Subject: [PATCH] gallery helper --- content/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/models.py b/content/models.py index e36aed0..4f44f8e 100644 --- a/content/models.py +++ b/content/models.py @@ -6,6 +6,7 @@ from django.core.validators import MaxLengthValidator from django.db import models from django.utils.html import mark_safe +from photologue.models import Photo, Gallery from markdownx.models import MarkdownxField from markdownx.utils import markdownify import ox @@ -140,6 +141,10 @@ class Content(models.Model): parts = [section, self.shortname] return '/' + '/'.join(parts) + def get_gallery(self): + gallery, created = Gallery.objects.get_or_create(slug=self.shortname) + return gallery + class Meta: managed = True db_table = 'content'