@Hyperboria

Как в django 2.0 теперь выводить превью картинок в админке?

Support for the allow_tags attribute on ModelAdmin methods is removed.


раньше у меня был такой метод:
def thumbnail(self):
        if self.photo:
            return f'<div style="display:flex; justify-content:space-around; "><div><a href="{self.photo.url}"><img src="{self.photo_thumbnail.url}"/></a></div></div>'
        return 'empty'

    thumbnail.short_description = 'Превью'
    thumbnail.allow_tags = True
  • Вопрос задан
  • 237 просмотров
Решения вопроса 1
sim3x
@sim3x
Deprecated since version 1.9:
In older versions, you could add an allow_tags attribute to the method to prevent auto-escaping. This attribute is deprecated as it’s safer to use format_html(), format_html_join(), or mark_safe() instead.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы