简体   繁体   English

使用include参数反向url查找

[英]Reverse url lookup with include parameter

Does anyone know how to make a reverse url lookup on a url with an include parameter? 有没有人知道如何使用include参数在URL上进行反向URL查找? For example I have the following url: 例如,我有以下网址:

 url(r'^photos/', include('photos.urls'), name="photos"),

And in my view i want to access it as follows 在我看来,我想按如下方式访问它

def photos_redirect(request, path):
    return HttpResponsePermanentRedirect(reverse('photos') + path)

But it get the following error: 但它得到以下错误:

Reverse for 'photos' with arguments '()' and keyword arguments '{}' not found.

You have to reverse to a single urlpattern. 您必须反转到单个urlpattern。 The photos URL pattern is including all the urlpatterns in photos.urls , so you have to choose which single URL you are wanting to direct to. photos的URL模式包括在所有的URL模式photos.urls ,所以你要选择你是想直接到单个URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM