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請求成功',
})