I have several APIs that historically work using id as a search field:
/api/organization/10
I have an interface that uses these api.
I am creating a new interface, and for some reason I would like to use slug instead of id:
/api/organization/my-orga
The API is built with the Django Rest Framework. In addition to changing the search field, api behavior should remain unchanged.
Is there a solution that allows my API to work with both slug and pk ? These two ways should give them the same results:
/api/organization/10 /api/organization/my-orga
Here is my API definition:
# urls.py router = DefaultRouter() router.register(r'organization', Organization) urlpatterns = router.urls
Thanks for your help.
source share