settings.py配置
REST_FRAMEWORK={ # 版本配置 "DEFAULT_VERSIONING_CLASS":"rest_framework.versioning.URLPathVersioning", 'ALLOWED_VERSIONS':['L1','L2'], # 允许的版本 'VERSION_PARAM': 'version', # 参数 'DEFAULT_VERSION': 'L1', # 默认版本}
urls.py
from django.conf.urls import url,includefrom django.contrib import adminurlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^api/(?P\w+)/',include('api.urls'))]