我是django領域的新手,並且想向django高手尋求幫助。如何使用下劃線分隔Django URL中的命名組?
現在我的網址已被 「/」,如下隔開的兩個命名組(product_slug和platform_slug):
/search/canon-eos-1d-x-mark-ii/dc-fever
當前URL配置:
url(r'^search/(?P<product_slug>[\w\-]+)$', CustomSearchView(), name='search_result_detail'),
url(r'^search/(?P<product_slug>[\w\-]+)/(?P<platform_slug>[\w\-]+)$', CustomSearchView(), name='search_result_platform'),
我想強調使用作爲分隔符使URL短而乾淨:
/search/canon-eos-1d-x-mark-ii_dc-fever
似乎它並不容易使用分隔符「/」以分隔命名組。 還有其他解決方案嗎?
謝謝丹尼爾。它運作良好。 – uses