如何在管理部分显示用户图片?,我正在寻找管理员的模板,我看不出如何......
我认为Django在部分代码(change_list模板)中显示字段,但jeje ..how?杰杰奥
{% block result_list %}
{% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
{% result_list cl %}
{% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
{% endblock %}
谢谢你们:)
答案 0 :(得分:0)
我们使用Justin Driscoll的精彩django-photologue。
如果正确安装了photologue(建议在安装过程中运行python manage.py plinit
)并正确提供媒体,则以下内容应为您提供易于使用的admin_thumbnail(),如下所示:
models.py
from photologue.models import Photo
class Entry(models.Model):
entry_photo = models.ForeignKey(Photo)
...
admin.py
def show_entry_thumbnail(item):
return item.entry_photo.admin_thumbnail()
show_entry_thumbnail.short_description = _('Entry Photo')
class ItemAdmin(admin.ModelAdmin):
list_display = (show_entry_thumbnail, ... )
答案 1 :(得分:0)
似乎还有一种使用sorl-thumbnail的替代方法:it's mentioned here。