How can I make two views in a DRF Generic viewset
use the same url_paths and url_names provided the make use of the same or different methods but different details
value, eg must can both be Get
methods but would have details=True
and details=False
on them
sample code for more clarity;
@action(methods=["get"], detail=False, url_path="list-users", url_name="users")
def get_users(self, request):
# code here
@action(methods=["get"], detail=True, url_path="users", url_name="users")
def get_user(self, request, id):
# code here
get_users work with this endpoint -> {{base_url}}/{{prefix}}/users
get_user does not work with -> {{base_url}}/{{prefix}}/{{user-id}}/users
but if I change the url_path and url_name to something else eg -> single-user
then the endpoint for getting a single user works
-> {{base_url}}/{{prefix}}/{{user-id}}/single-user
how can I solve this to make the users and user have the same url_name and url_path because the actions have detail as False
(users) and True
(user) for both of them respectively
NB; Also please note that this viewset does not make use of any model