Django: Display image in admin interface

前端 未结 7 1852
盖世英雄少女心
盖世英雄少女心 2020-11-28 23:00

I\'ve defined a model which contains a link an image. Is there a way to display the image in the model items list? My model looks like this:

class Article(mo         


        
7条回答
  •  忘掉有多难
    2020-11-28 23:36

    (I'm using Django 1.5) In addition to following the steps in the accepted answer, I ALSO had to mark the image tag as being "safe"

    To do this, wrap the return value with the mark_safe method of django.utils.safestring package.

    code example: https://stackoverflow.com/a/14075441/1063031

    django docs: https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping

提交回复
热议问题