Hen*_*son 9 python django django-2.0
我想使用包含正斜杠的参数调用 Django URL。例如,我想mysite.com/test/用'test1/test2'. (例如,天真地,网址是mysite.com/test/test1/test2)
urls.py:
urlpatterns = [
path('test/<test_arg>/', views.test, name='test'),
]
Run Code Online (Sandbox Code Playgroud)
访问以下任一失败:
mysite.com/test/test1/test2mysite.com/test/test1%2Ftest2 (%2F 是正斜杠的标准 URL 编码)出现以下错误:
错误:
Using the URLconf defined in test.urls, Django tried these URL patterns, in this order:
reader/ test/<test_arg>/
admin/
The current path, test/test1/test2/, didn't match any of these.
Run Code Online (Sandbox Code Playgroud)
我希望使用 1 中的路径失败,但我很惊讶 2 中的路径失败。
解决这个问题的正确方法是什么?
使用 Django 2.0.2
| 归档时间: |
|
| 查看次数: |
2017 次 |
| 最近记录: |