diff options
-rw-r--r-- | app/books/models.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/app/books/models.py b/app/books/models.py index 004ed8c..8e8b485 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -109,20 +109,20 @@ class BookHighlight(models.Model): body_html = models.TextField(blank=True) class Meta: - ordering = ('-page', '-date_added') + ordering = ('-date_added', '-page',) + get_latest_by = 'date_added' def __str__(self): - return "%s%s" % (self.book.title, self.id) - - def body_html_old(self): - return markdown_to_html(self.body_markdown) + return "%s - %s" % (self.book.title, self.id) def save(self, *args, **kwargs): + if not self.pk: + if self.book_id is None: + self.book = BookHighlight.objects.latest().book self.body_html = markdown_to_html(self.body_markdown) - if not self.book: - self.book = BookHighlight.objects.latest().book super(BookHighlight, self).save() + class BookSitemap(Sitemap): changefreq = "never" priority = 0.7 |