根据url参数过滤查询集

时间:2018-11-19 14:36:21

标签: python django

如何在视图中的URL中获取参数并基于此过滤查询? 我也想在网址中有多个参数,它们都是可选的? 为了清楚地传达需求,请看一下urls.py中的网址:

url(r'^search/(?P<insurance>\D+)/(?P<area>\D+)/(?P<slug>\D+)/(?P<illness>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/(?P<area>\D+)/(?P<slug>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/(?P<slug>\D+)/(?P<illness>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/(?P<area>\D+)/(?P<illness>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/(?P<area>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/(?P<slug>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/(?P<area>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/(?P<illness>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<insurance>\D+)/$',new_search,name='new_search'),


url(r'^search/(?P<area>\D+)/(?P<slug>\D+)/(?P<illness>\D+)$',new_search,name='new_search'),
url(r'^search/(?P<area>\D+)/(?P<slug>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<area>\D+)/(?P<illness>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<area>\D+)/$',new_search,name='new_search'),


url(r'^search/(?P<slug>\D+)/(?P<illness>\D+)/$',new_search,name='new_search'),
url(r'^search/(?P<slug>\D+)/$',new_search,name='new_search'),

如何基于views.py中的那些网址过滤查询集

0 个答案:

没有答案