Django 管理员并显示缩略图
问题描述
我正在尝试在 Django 管理中显示缩略图,但我只能看到图像的路径,而不是渲染的图像.我不知道我做错了什么.
I'm trying to show thumbnail images in Django admin, but I can only see the path to the images, but not the rendered images. I don't know what I'm doing wrong.
服务器媒体网址:
功能模型:
admin.py:
结果:
推荐答案
这在 photologue(参见 models.py
,稍作修改以删除不相关的内容):
This is in the source for photologue (see models.py
, slightly adapted to remove irrelevant stuff):
list_display
位看起来也一样,我知道这很有效.对我来说唯一可疑的是您的缩进-在 models.py
代码末尾以 image_img
开头的两行应该与 def image_img(self):
,像这样:
The list_display
bit looks identical too, and I know that works. The only thing that looks suspect to me is your indentation - the two lines beginning image_img
at the end of your models.py
code should be level with def image_img(self):
, like this:
这篇关于Django 管理员并显示缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!