Python:防止URL在Django视图中编码

Python: Prevent URL from encoding in Django view

在 Django 视图中 URL 是这样动态生成的

<a href="{% url 'users' info.user_id info.full_name '?tab=tags' %}" role="button" class="my">votes</a>

Django 自动编码这个 URL 。但我不喜欢这个,因为用户无法查看这个编码的 url .

我已尝试按照语义来禁用此功能,但 none 它们有效。

  1. {% autoesacpe off %} <a href="{% url 'users' info.user_id info.full_name '?tab=tags' %}"role="button" class="my">votes</a> {% endautoesacpe %}

  2. <a href="{% url 'users' info.user_id info.full_name '?tab=tags'|safe %}" role="button" class="my">votes</a>

    注意:使用 Djnago 1.7

{% url %}标签后添加GET参数:

<a href="{% url 'users' info.user_id info.full_name %}?tab=tags">