diff options
Diffstat (limited to 'app/books/models.py')
-rw-r--r-- | app/books/models.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/books/models.py b/app/books/models.py index c3c15f4..59f0ae3 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -1,6 +1,8 @@ +import datetime from django.db import models from django.urls import reverse -from django.utils.encoding import force_text +from django.apps import apps +from django.utils.html import format_html from django.conf import settings from django.template.defaultfilters import slugify @@ -25,7 +27,6 @@ class Book(models.Model): publish_date = models.CharField(max_length=40, blank=True, null=True) publish_place = models.CharField(max_length=100, blank=True, null=True) openlib_url = models.CharField(max_length=400, blank=True, null=True) - amazon_url = models.CharField(max_length=400, blank=True, null=True) RATINGS = ( ('1', "1 Star"), ('2', "2 Stars"), @@ -60,19 +61,18 @@ class Book(models.Model): @property def get_previous_admin_url(self): n = self.get_previous_by_pub_date() - return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] ) + return reverse('admin:%s_%s_change' % (self._meta.app_label, self._meta.model_name), args=[n.id]) @property def get_next_admin_url(self): model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name) try: - return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] ) + return reverse('admin:%s_%s_change' % (self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk]) except model.DoesNotExist: return '' def admin_thumbnail(self): - return force_text('<a href=""><img src="%s" width="100" style="width:100px"></a>' % (self.get_image_url())) - admin_thumbnail.allow_tags = True + return format_html('<img src="%s" width="100" style="width:100px" />' % (self.get_image_url())) admin_thumbnail.short_description = 'Thumbnail' def save(self, *args, **kwargs): |