Django Admin Bild-Vorschau
EntwurfDjangoPythonAdmin
# 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')
Metaebene
★★★★★
- Datum
- 10. März 2020vor mehr als 4 Jahren
- Sprache
- de
- Aktualisiert am
- 20. Oktober 2024