Django Admin Bild-Vorschau
DraftDjangoPythonAdmin
# admin.py from django.contrib import admin from django.utils.safestring import mark_safe from blog import models @admin.register(models.Article) class ArticleAdmin(admin.ModelAdmin): list_display = ( '...', 'image_preview', '...', ) def image_preview(self, instance): if not instance.image: return None return mark_safe('<a href="%s" target="_blank" class="profileImage"><img src="%s" height="128"></a>' % (instance.image.url, instance.list_image) ) image_preview.short_description = _('List image')
Meta data
★★★★★
- Date
- March 10, 2020over 4 years ago
- Language
- de
- Updated on
- October 20, 2024