diff options
Diffstat (limited to 'app/posts/models.py')
-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 |