【问题标题】:Django templates tag errorDjango模板标签错误
【发布时间】:2011-03-04 09:53:28
【问题描述】:
def _table_(request,id,has_permissions):
    dict = {}
    dict.update(get_newdata(request,rid))
    return  render_to_response('home/_display.html',context_instance=RequestContext(request,{'dict': dict, 'rid' : rid, 'has_permissions' : str(has_permissions)}))

在模板中代码如下,

{% if has_permissions == "1" %}
<input type="button" value="Edit" id="edit" onclick="javascript:edit('{{id}}')"  style="display:inline;"/>&nbsp;&nbsp;&nbsp;&nbsp;
{% endif %}

has_permissions 行中存在模板错误。这里有什么问题? has_permissions 的值为 1 或 0。

【问题讨论】:

  • 请在您的问题中包含原始错误消息。

标签: python django django-templates django-views


【解决方案1】:

1.2 之前的 Django 版本不支持 {% if %} 中的关系运算符。请改用{% ifequal %} 或裸{% if %}

【讨论】:

    猜你喜欢
    • 2012-09-10
    • 2016-08-12
    • 2014-07-17
    • 2012-11-08
    • 2011-10-05
    • 2018-03-14
    • 2021-02-18
    • 1970-01-01
    • 2011-02-09
    相关资源
    最近更新 更多