diff options
author | luxagraf <sng@luxagraf.net> | 2020-04-12 16:12:47 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2020-04-12 16:12:47 -0400 |
commit | 9ce8f0ef97d06750c323785828620becf375058f (patch) | |
tree | f85c2c971be6ce5d30b13e8b393e7f5aa1e3d457 | |
parent | e9e7723edee2aade26f49bcabbf97d84dc9e7dcb (diff) |
changed post_save to just do it in save
-rw-r--r-- | app/jrnl/models.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py index b9ebaf8..69d1178 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -199,6 +199,12 @@ class Entry(models.Model): self.featured_image.sizes.add(s) self.featured_image.sizes.add(ss) self.featured_image.save() + if old.title != self.title or 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 + related.slug = self.slug + related.save() + super(Entry, self).save(*args, **kwargs) @@ -280,12 +286,6 @@ def post_save_events(sender, update_fields, created, instance, **kwargs): """ if created: related, c = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pub_date, title=instance.title, slug=instance.slug) - if update_fields: - if 'title' in update_fields or 'slug' in update_fields: - related, c = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pub_date) - related.title = instance.title - related.slug = instance.slug - related.save() # from django_comments.signals import comment_will_be_posted # from django_comments import akismet |