I am trying to implement multiple URL patterns pointing to one Class Based View in my django 2+ app.
My urls:
path('<slug:slug>', views.OfferDetailView.as_view(), name='show'),
path('<slug:slug>/<str:status>', views.OfferDetailView.as_view(), name='show'),
path('<slug:slug>/<str:status>/<uuid:application>', views.OfferDetailView.as_view(), name='show'),
path('<slug:slug>/<uuid:application>', views.OfferDetailView.as_view(), name='show'),
Let's say that "ABC12
" is my slug here. What is my expected behaviour:
- when user enters /ABC12: view's kwargs status and application are Nones, slug is ABC12
- when user enters /ABC12/new: view's kwargs status is "new" and application is None, slug is ABC12
- when user enters /ABC12/new/6eba5dbf-220b-4913-a359-f93fab3153d1: view's kwargs status is "new" and application kwarg is "6eba5dbf-220b-4913-a359-f93fab3153d1", slug is ABC12
- when user enters /ABC12/6eba5dbf-220b-4913-a359-f93fab3153d1: view's kwargs status is None and application kwarg is "6eba5dbf-220b-4913-a359-f93fab3153d1", slug is ABC12
however, when I type url: /ABC12/6eba5dbf-220b-4913-a359-f93fab3153d1
kwargs are:
{'slug': 'ABC12', 'status': '6eba5dbf-220b-4913-a359-f93fab3153d1'}
(I've expected that there should be not status kwarg, and 'application' kwarg should be "6eba5dbf-220b-4913-a359-f93fab3153d1").
How can I achieve this? I don't want to end up with multiple views.