我有一个URL,它接受可能包含空格的查询参数。我知道它看起来很简单,但我的正则表达式对我不起作用。
这是我的网址格式定义:
url(
r'^item_info_details_view/(?P<itemno>[\w \/&-]+)/$',
'purchasing.views.item_info_details_view'),
itemno可以是包含空格的FAX MODEM
之类的短语。
但是,当我将这样的参数传递给它时,浏览器中的URL是
http://localhost/item_info_details_view/FAX%20MODEM/
并显示此调试信息:
Using the URLconf defined in urls, Django tried these URL patterns, in this order:
^$
The current URL, item_info/FAX MODEM/, didn't match any of these.
答案 0 :(得分:0)
问题似乎不是空间,而是你在urlconf中有“item_info_details_view”而在实际网址中有“item_info”。
(由@ daniel-roseman撰写)