Introduction

The article introduces how to use DRF-Nested-Routers framework https://github.com/alanjds/drf-nested-routers 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

Diagram

Image for post

#django #django-rest-framework

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