【问题标题】:Django, Display thumbs in Admin?Django,在管理员中显示拇指?
【发布时间】:2010-11-21 00:52:22
【问题描述】:

如何在管理部分显示用户图片?,我正在查看管理的模板,但我看不到如何...

我认为 Django 会在部分代码(change_list 模板)中显示字段,但是 jeje ..如何?哎呀

{% 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 %}

谢谢大家:)

【问题讨论】:

    标签: django-admin django-templates


    【解决方案1】:

    我们使用 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, ... )
    

    【讨论】:

    • 大家好,django-photologue 很好,但画廊用户有问题.. 我想上传图片并显示拇指
    【解决方案2】:

    似乎还有一种使用 sorl-thumbnail 的替代方法:it's mentioned here。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-10
      • 1970-01-01
      • 2021-09-14
      • 2011-01-31
      • 2019-08-12
      相关资源
      最近更新 更多