drf安装
from rest_framework.views import APIView
from rest_framework.request import Request
from rest_framework.response import Response
drf的安装步骤
drf具体的使用
from app import views
urlpatterns = [
url(r'^teachers/', views.Teachers.as_view()),
]
from rest_framework.views import APIView
from rest_framework.response import Response
class Teachers(APIView):
def get(self, request, *args, **kwargs):
salary = request.GET.get('salary')
print(salary)
return Response({
'status': 2,
'msg': 'get请求成功',
})
def post(self, request, *args, **kwargs):
salary = request.data.get('salary')
print(salary)
return Response({
'status': 2,
'msg': 'post请求成功',
})