diff options
author | luxagraf <sng@luxagraf.net> | 2020-08-25 20:15:12 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2020-08-25 20:15:12 -0400 |
commit | 3a58df4b950f43c3cb8e6d654d58d4c3e7cdeced (patch) | |
tree | 8c60f9b1242c5fee5844ab9d7c7058dabdf27c3e /app/posts | |
parent | 916b3b7a6cf8b59b1c377bbc6a9d3272a8045588 (diff) |
added option for field notes without featured images
Diffstat (limited to 'app/posts')
-rw-r--r-- | app/posts/models.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/posts/models.py b/app/posts/models.py index 4a43457..dc3ae4c 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -174,11 +174,12 @@ class Post(models.Model): self.featured_image = LuxImage.objects.latest() old = type(self).objects.get(pk=self.pk) if self.pk else None if old and old.featured_image != self.featured_image: # Field has changed - s = LuxImageSize.objects.get(name="featured_jrnl") - ss = LuxImageSize.objects.get(name="picwide-med") - self.featured_image.sizes.add(s) - self.featured_image.sizes.add(ss) - self.featured_image.save() + if self.featured_image: + s = LuxImageSize.objects.get(name="featured_jrnl") + ss = LuxImageSize.objects.get(name="picwide-med") + self.featured_image.sizes.add(s) + self.featured_image.sizes.add(ss) + self.featured_image.save() if old and old.title != self.title or old and old.slug != self.slug: related, c = RelatedPost.objects.get_or_create(model_name=self.get_content_type(), entry_id = self.id, pub_date=self.pub_date) related.title = self.title |