通过URL访问的Django错误端点

dor*_*far 1 python django


我的Django应用程式中有2个网址格式:

url_patterns = [
    url(r'test/read/all/', TestViews.test_read_all),
    url(r'test/read/all/custom/', TestViews.test_read_all_custom)
]
Run Code Online (Sandbox Code Playgroud)

我的问题是:当我尝试访问test/read/all/custom/URL时,请求被定向到test/read/all/URL(TestViews.test_read_all被触发而不是TestViews.test_read_all_custom

编辑

两种端点方法都具有相同的api视图修饰符(@api_view(["GET"])

jua*_*ith 6

您必须在网址末尾添加字符串符号“ $”的末尾:

url(r'^test/read/all/$', TestViews.test_read_all),
Run Code Online (Sandbox Code Playgroud)