1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| from django.http import HttpResponse from django.shortcuts import render
# Create your views here. from rest_framework.views import APIView from rest_framework.request import Request
class ParamVersion(object): def determin_version(self,request): version = request.query_params.get('version') return version
class UsersView(APIView): def get(self,request,*args,**kwargs): # request首先是先从自己的类中拿,如果自己的类中没有,就去原生的那个类中的去拿, # 否则就会抛出异常 # version = request._request.GET.get('version') # print(version) # version = request.query_param.get('version') # 和request._request.GET.get('version')取值完全一样 # print version return HttpResponse('用户列表')
|