0

I have to route the following URL pattern to view api/v1/{resourceId}/owners in DRF

But the problem is resourceID contains / in it. eg api/v1/somethings/value/owners the additional / causing get 404 resource not found exception

Is there way to route the URL and get resourceID in view

My urls.py

path('api/v1/<str:resource_id>/owners', ResourceOwnershipView.as_view())

views.py

class ResourceOwnershipView(APIView):

    def get(self, request: HttpRequest, resource_id: str) -> Response:
        # do something with resourceID

1 Answer 1

1

<str:> probably doesn't allow slashes in it. I would try to use regular expression version of routing definition re_path:

https://docs.djangoproject.com/en/4.1/ref/urls/#re-path

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.