Learn how to register versioned DRF endpoints declaratively and compare the approach with explicit Django URL routing.
Package disclosure: The author is the creator, owner, and maintainer of django-api-versioning .
When an API evolves, existing clients may need to continue using /api/v1/ while newer clients use /api/v2/ . The challenge is deciding which implementation serves each version and maintaining the corresponding URL routes.
Django API Versioning provides declarative endpoint registration for Django and Django REST Framework (DRF). Instead of writing a separate path() declaration for every version, you define endpoint availability alongside the view implementation.
This article demonstrates the package's approach and compares it with explicit Django URL routing. The examples use integer version identifiers such as 1 and 2 ; the default URL configuration renders them as v1 and v2 .
1. Declarative versioned endpoints
Consider an API that exposes a list and detail endpoint for books.…