[Answered ]-Django url dispetcher route by id

1👍

Your problem comes from your url settings your should add primary key to the url. Change this

path('V1/api/users/', UserAPI.as_view(), name='user')

To this

path('V1/api/users/<pk>/', UserAPI.as_view(), name='user'),
👤Godda

0👍

path('V1/api/users/<int:user_id>', UserAPI.as_view(), name='user'),


class UserApi(generics.RetrieveAPIView):

    permission_classes = [permissions.IsAuthenticated,]
    serializer_class = UserSerializer

    def get(self, request, user_id, format=None):

        print(user_id) # do whatever you want with the user id

Leave a comment