【问题标题】:django: problems with sorl-thumbnaildjango:sorl-thumbnail 的问题
【发布时间】:2012-03-21 18:40:35
【问题描述】:

当我将 sorl-thumbnail 引入我的模板时,它会中断。

这是有效的部分:

{% for product in products %}
    <ul class="thumbnails">
        {% for productImage in product.images.all %}
            ...
        {% endfor %}
...
{% endfor %}

这不是:

{% load thumbnail %}
{% for product in products %}
    <ul class="thumbnails">
        {% for productImage in product.images.all %}
            <li class="span4">
                {% thumbnail productImage.image "160x200" as im %}
                    <img src="{{ im.url }}" alt = "" />
                {% endthumbnail %}
            </li>   
        {% endfor %}
...
{% endfor %}

这就是发生的事情:

Exception Type: TemplateSyntaxError
Exception Value:    
Caught DatabaseError while rendering: current transaction is aborted, commands ignored until end of transaction block

1   {% load thumbnail %}
2   {% for product in products %}

第二行标记为红色。

另外,如果我只使用 {% load thumbnail %} 标签而忽略其余部分,一切都很好(除了我无法显示那些漂亮的缩略图)。

对可能出现的问题有什么想法吗?

【问题讨论】:

    标签: django sorl-thumbnail


    【解决方案1】:

    可能会回答我自己的问题...设置

    THUMBNAIL_DEBUG = True
    

    导致此错误:

    Caught DatabaseError while rendering: relation "thumbnail_kvstore" does not exist
    LINE 1: ..._kvstore"."key", "thumbnail_kvstore"."value" FROM "thumbnail...
    

    我不小心关闭了 memcached,忘记更新我的 sorl 数据库。

    【讨论】:

    • 哦,其实我有。但后来我回滚到早期的修订版,忘了再做一次:)
    猜你喜欢
    • 2012-01-17
    • 2011-12-31
    • 2011-08-06
    • 2011-09-12
    • 2011-09-11
    • 2021-10-07
    • 1970-01-01
    • 2015-05-12
    • 2011-09-05
    相关资源
    最近更新 更多