2024-03-29 09:16:47 发布
网友
我需要在单个url regex中支持以下url。在
/hotel_lists/view/ /photo_lists/view/ /review_lists/view/
如何在单个视图中支持以上所有URL?在
我试过下面这样的方法
编辑: 酒店,照片,评论只是例子。第一部分是动态的。第一部分可以是任何东西。在
如果要捕获视图中的资源类型,可以执行以下操作:
url(r'^(?P<resource>hotel|photo|review)_lists/view/$', 'admin.views.customlist_handler'),
或者让它更通用
在视图中
def customlist_handler(request, resource): #You have access to the resource type specified in the URL. ...
您可以在named URL pattern groups here上阅读更多内容
如果要捕获视图中的资源类型,可以执行以下操作:
或者让它更通用
^{pr2}$在视图中
您可以在named URL pattern groups here上阅读更多内容
相关问题 更多 >
编程相关推荐