django simple to use restframework

download

pip install djangorestframework

use

# Add 'rest_framework' to set your INSTALLED_APPS: 
INSTALLED_APPS = [ 
    ... 
    'rest_framework' , 
]
# 视图函数 app01/views.py
from rest_framework.views import APIView

class Order(APIView):
    def get(self, request, *args, **kwargs):
        return HttpResponse("GET")

    def post(self, request, *args, **kwargs): return HttpResponse("POST") # 配置路由 settings.py from app01 import views urlpatterns = [ ... url(r'^order/', views.Order.as_view()) ]

django project then you can start using the GET, POST access http: // localhost: port / order / a.

Guess you like

Origin www.cnblogs.com/aaronthon/p/12549934.html