【问题标题】:Why does Aptana run the comment in Django template?为什么 Aptana 在 Django 模板中运行注释?
【发布时间】:2014-10-19 22:48:10
【问题描述】:

这是一种奇怪的行为,或者我错过了更深层次的东西。

在我的 Django 模板中,此代码 sn-p 导致错误:

{% if scale.pk %}
<!-- <a class='btn btn-success' style = 'float:left;' href="{% url "scale_update" pk=scale.pk %}">Edit Scale</a> -->

<a class='btn btn-danger' style = 'float:right;' href="{% url "scale_delete" pk=scale.pk %}">Delete Scale</a>
{% endif %}

当我加载页面时,我看到了这个错误:

NoReverseMatch at /scales/
Reverse for 'scale_update' with arguments '()' and keyword arguments '{u'pk': 1}' not found.

另一方面,当我完全删除评论部分时,它会按预期工作。只有一个 Python 实例在运行。

我是否缺少有关 html 或 django 的内容?还是 Aptana 中的错误?

【问题讨论】:

    标签: html django templates aptana3


    【解决方案1】:

    Django 不关心 HTML cmets。它将呈现在页面上找到的所有标签。据它所知,您希望将该文本呈现为评论。

    如果您根本不想渲染某些内容,则需要使用 Django 注释标记,而不是 HTML 标记:{# ... #} 用于单行,{% comment %}...{% endcomment %} 用于多行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-17
      • 1970-01-01
      • 2019-02-19
      • 1970-01-01
      • 2010-10-17
      • 1970-01-01
      • 2011-12-17
      相关资源
      最近更新 更多