我们正在将我们的 API 从 Django - Piston 移植到 Django-TastyPie。一切都很顺利,直到我们做到了:
应用程序的 urls.py
url(r'^upload/', Resource(UploadHandler, authentication=KeyAuthentication()), name="api-upload"),
url(r'^result/(?P<uuid>[^//]+)/', Resource(ResultsHandler, authentication=KeyAuthentication()), name="api-result")
这使用了活塞,所以我们想把它改成美味派的东西
url(r'^upload/', include(upload_handler.urls), name="api-upload"),
url(r'^result/(?P<uuid>[^//]+)/', include(results_handler.urls), name="api-result")
但我们被困在这个错误上
找不到带有参数“()”和关键字参数“{'uuid':'fbe7f421-b911-11e0-b721-001f5bf19720'}”的“api-result”的反向。
结果的Debugpage:
使用 MelodyService.urls 中定义的 URLconf,Django 按以下顺序尝试了这些 URL 模式:
^melotranscript/ ^upload/ ^melotranscript/ ^result/(?P[^//]+)/ ^(?Presultshandler)/$ [name='api_dispatch_list'] ^melotranscript/ ^result/(?P[^// ]+)/ ^(?Presultshandler)/schema/$ [name='api_get_schema'] ^melotranscript/ ^result/(?P[^//]+)/ ^(?Presultshandler)/set/(?P\w [\w/;-]*)/$ [name='api_get_multiple'] ^melotranscript/ ^result/(?P[^//]+)/ ^(?Presultshandler)/(?P\w[\w/ -]*)/$ [name='api_dispatch_detail'] ^melotranscript/ ^processed/(?P. )$ ^admin/doc/ ^TOU/$ [name='TOU'] ^$ [name='index'] ^admin/ ^doc/(?P. )$ 当前的 URL,melotranscript/result/fbe7f421-b911-11e0-b721-001f5bf19720/,与其中任何一个都不匹配。
有谁知道问题吗?这可能是一个非常愚蠢/愚蠢的问题......