标签:使用 orm import efault 控制 版本 return war view
from rest_framework.versioning import URLPathVersioning
from rest_framework.views import APIView
from django.http import HttpResponse
class Index(APIView):
versioning_class = URLPathVersioning
def get(self, request, *args, **kwargs):
return HttpResponse('version: %s' % request.version)
REST_FRAMEWORK = {
'VERSION_PARAM': 'version',
'DEFAULT_VERSION': 'v1',
}
from django.conf.urls import url, re_path
from rest_framework.urlpatterns import format_suffix_patterns
from . import views
urlpatterns = [
re_path(r'^index/(?P<version>v\d+)', views.Index.as_view()),
]
标签:使用 orm import efault 控制 版本 return war view
原文地址:https://www.cnblogs.com/ivy-blogs/p/11651378.html