show uploaded URLImage in admin
authorTero Marttila <terom@fixme.fi>
Sat, 31 Aug 2013 19:21:41 +0300
changeset 64 b968f33d780c
parent 63 9d1184cdbd16
child 65 b6ce70e51bce
show uploaded URLImage in admin
qrurls/admin.py
--- a/qrurls/admin.py	Sat Aug 31 19:11:37 2013 +0300
+++ b/qrurls/admin.py	Sat Aug 31 19:21:41 2013 +0300
@@ -228,6 +228,11 @@
     )
 
 class URLImageAdmin (admin.ModelAdmin) :
+    def show_image(self, obj):
+        return """<img src="{url}" style="max-width: 480px"/>""".format(url=obj.get_absolute_url())
+    show_image.short_description = "Image"
+    show_image.allow_tags = True
+
     list_display = (
         'title',
         'uploaded',
@@ -236,9 +241,11 @@
     fields = (
         'image',
         'title',
+        'show_image',
     )
     readonly_fields = (
         'uploaded',
+        'show_image',
     )
     
     inlines = (URLItemInline, )