嗨, 大家好: 网站在新年后正式开通,欢迎大家加入我们,共同维护一个良好氛围的中国技术社区。 欢迎举报不良帖子,欢迎提供建议。
我们的QQ群:136102234,欢迎进群找答案,里边会有很多资深的大师们。 point overflow

后台的图片字段正常展示一般为url,不太适合审核之类的工作的。 所以显示图片就比较重要。 如何展示图片?

asked 2017-10-13 09:29:26

jkant's gravatar image

jkant ♦♦
11133138139
accept rate: 3%


在admin.py下:

class yourmodleAdmin(admin.ModelAdmin):

def image_tag(self, yourmodle):
    return format_html('<img src="{}" />'.format(yourmodle.yourmodlecolumn))

image_tag.short_description = 'Image'
list_display = ('yourmodlecolumn')
list_per_page = 10

admin.site.register(yourmodle,yourmodleAdmin)

link

answered 2017-10-13 09:33:34

jkant's gravatar image

jkant ♦♦
11133138139
accept rate: 3%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×2
×1
×1

Asked: 2017-10-13 09:29:26

Seen: 1,316 times

Last updated: 2017-10-13 09:33:34