I want to make my url to accept the optional parameters only when given. I am unable to make the parameters optional/non-capturing.
re_path(r'^users/(?:(?P<sort_by>\d+)/)?$', views.UserListView.as_view(), name='user_list'),
I want this url to accept a slug
field only when provided to the view. How can I do this?
It is showing an error
Reverse for 'user_list' with keyword arguments '{'sort_by': 'username'}' not found. 1 pattern(s) tried: ['admin/users/(?:(?P<sort_by>\\d+)/)?$']
when I passed sort_by='username'