Django multiple slug urls

Viewed 89

I have two kind of slugs:

path('<slug:category_slug>/', butik_views.category_page_view),  
path('<slug:shop_page_slug>/', butik_views.shop_page_view),

Category slugs are working fine, but if I open a shop_page URL, it looks in category view and not in the shop_page_view. Is there something i missed?

1 Answers

Both paths are identical, so if you enter a slug, it will always "fire" the first view.

You thus should make the two paths different, and preferrably non-overlapping, so for example with:

path('category/<slug:category_slug>/', butik_views.category_page_view),  
path('shop/<slug:shop_page_slug>/', butik_views.shop_page_view),
Related