Versioning is very simple.
Create folder in your app and name it to `v1`
Like this image :
https://i.stack.imgur.com/O8FGC.png
yourApp > urls.py should be like this :
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('v1/', include('api.v1.urls')),
]
Then create `urls.py` in v1 folder
it should somthing like this :
from django.urls import path, include
from api.v1.classes.Plan import listPlan
from api.v1.classes.preInvoce import preInvoce
urlpatterns = [
path('plan/list', listPlan.as_view(), name="listPlans"),
path('plan/buy', preInvoce.as_view(), name="preInvoice"),
]
If you want have version 2 you need to create new folder called v2 and have urls.py in it.
and your app urls.py should be like this:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('v1/', include('api.v1.urls')),
path('v2/', include('api.v2.urls')),
]
Put your own and new urls in v2/urls.py
Your final v1 urls like this :
localhost:8000/v1/planList
Your final v2 urls like this :
localhost:8000/v2/newUrlInV2
Both v1 and v2 urls should works correctly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…