最佳答案
这是我在模板中的代码。
{% if 'index.html' in "{{ request.build_absolute_uri }}" %}
'hello'
{% else %}
'bye'
{% endif %}
现在我的 url 值当前是 "http://127.0.0.1:8000/login?next=/index.html"
即使字符串中有 "index.html"
,它仍然打印再见。
当我在 pythonshell 中运行相同的代码时,它能正常工作。