From 1274988c5fed1d8f23b244fba7408d6883d138cf Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 15 Mar 2019 21:57:12 -0600 Subject: added related items complete with template and styles --- app/sightings/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/sightings') diff --git a/app/sightings/models.py b/app/sightings/models.py index 5723776..3852b1c 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -12,7 +12,7 @@ from django.conf import settings from bs4 import BeautifulSoup from locations.models import Location -from photos.models import LuxImage +from photos.models import LuxImage, LuxImageSize from utils.next_prev import next_in_order, prev_in_order from utils.util import render_images, extract_main_image, markdown_to_html @@ -75,7 +75,7 @@ class AP(models.Model): return self.common_name def get_image_url(self): - return "%s%s" % (settings.IMAGES_URL, self.image.url.split("media")[1][8:]) + return "%s%s" % (settings.IMAGES_URL, self.image.image.url.split("media")[1][8:]) def get_absolute_url(self): return reverse("sightings:detail", kwargs={"slug": self.slug}) @@ -121,6 +121,9 @@ class AP(models.Model): main_image = extract_main_image(self.body_markdown) if main_image: self.image = main_image + s = LuxImageSize.objects.get(name="featured_jrnl") + self.image.sizes.add(s) + self.image.save() self.slug = slugify(self.common_name[:50]) super(AP, self).save(*args, **kwargs) -- cgit v1.2.3-70-g09d2