我有这个锚链接:
<a href="/question/tag/1/1/?list_id={{title}}">{{title}}</a>
Run Code Online (Sandbox Code Playgroud)
有时,这个标题有一些内容+(添加运算符),如:"Django + Python"
但是当它直接放在锚链接上时,交付的网址将是:
http://127.0.0.1:8080/question/tag/1/1/?list_id=Django + Python
Run Code Online (Sandbox Code Playgroud)
这将最终导致检索问题,因为url解码器认为list_id GET = DjangoPython.
那么,有谁知道如何避免这个问题?请注意,我不想将锚链接更改为输入按钮.
我执行此操作以检索查询集:
Name.objects.values_list('name', flat=True)
Run Code Online (Sandbox Code Playgroud)
它返回以下结果:
[u'accelerate', u'acute', u'bear', u'big']
Run Code Online (Sandbox Code Playgroud)
结果都是unicode(u').如何将它们全部删除以便得到结果:
['accelerate', 'acute', 'bear', 'big']
Run Code Online (Sandbox Code Playgroud) 我尝试在stackoverflow上关注选择列表中选择的选项的一些示例,但仍然,我无法使其工作.
这是我的代码片段
<select name="topic_id" style="width:90%">
{% for t in topics %}
<option value="{{t.id}}" {% if t.id == topic_id %} selected="selected" {% endif %}>{{t.title}}{{t.id}}</option>
{% endfor %}
</select>
Run Code Online (Sandbox Code Playgroud)
我从views.py中的param ['topic_id']中获取了topic_id.
谢谢!