I want to know what is the best practices for controlling the Version for Mobile App APIs.
Requirement
- If I change something in my database previous version of the app should not be affected.
- Currently I'm doing like...
path('v1/auth/', include('authentication.urls')),
path('v2/auth/', include('authentication.urls2')), # Example
path('v1/api/', include('contentstudio.urls')),
Django REST Framework has support for many different methods of versioning you api. Check out the docs to find which one suits you best.
According to the docs, the
AcceptHeaderVersioning
method "is generally considered as best practice". ie. you put the version in the Accept header like so:Using any of these methods you will have access to
request.version
in your views to determine the behavior of the different versions.