The article introduces how to use DRF-Nested-Routers framework to create URLs for nested resources. In this tutorial, our target is to create APIs for getting libraries and books.

/api/libraries/ -> Get list of libraries
/api/libraries/{library_id}/books/ -> Get list of book in a library
/api/libraries/{library_id}/books/{book_id} -> Get details of a book


Image for post

#django #django-rest-framework

Using Nested Routers DRF-Nested Routers in Django Rest framework
6.15 GEEK