from django.http import JsonResponse
from django.core.paginator import Paginator ,PageNotAnInteger ,EmptyPage
from django.views.decorators.csrf import csrf_exempt
def foo(req):
return JsonResponse({'status': 0, 'msg': 'success'})
from backend import views_api
urlpatterns = [
url(r'^api/', views_api.foo),
]
访问: http://127.0.0.1:8000/api/foo