所以我用Django创建了一个应用程序。我在应用程序的其他部分传递了1个参数,但是当添加两个参数时,我想我得到了错误的正则表达式。
这是url.py的一部分:
url(r'^(?P<uuid>(\d+))/(?P<malware>(\d+))/$', views.execute, name='execute'),这是html文件:
<li><a tabindex="-1" href="{% url 'execute' malware=malware uuid=uuid %}"> {{ vm }}</a></li>这是错误:
Reverse for 'execute' with keyword arguments '{'uuid': '2932b679-787a-48e0-a4f7-be020b8e4734', 'malware': 'calc.exe'}' not found. 1 pattern(s) tried: ['(?P<uuid>(\\d+))/(?P<malware>(\\d+))/$']我假设这个错误是由于正则表达式造成的。任何帮助都将不胜感激。
编辑:
这是固定的-使用以下字符串
url(r'^(?P<uuid>([0-9\-a-f]+))/(?P<malware>[a-z.]+)/$', views.execute, name='execute'), is the working string, perfect5th you've been an absolute kingpin here, thanks! – dipl0 8 hours ago 发布于 2017-07-21 08:12:21
您要查找的恶意软件值为\d+ (全数字),但传入值'calc.exe'。尝试更改您的正则表达式模式以匹配所有预期值。也许是[a-z.]+
同样,您的<uuid>模式可能应该更像[0-9\-a-f]+。
https://stackoverflow.com/questions/45226885
复制相似问题