【发布时间】:2017-08-21 06:39:51
【问题描述】:
我写了 hello word 程序,想返回 json 格式的数据,但它不起作用。请查看我的代码 网址文件
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from login import views
urlpatterns = [
url(r'^hello_world/$', views.hello_world),
]
查看文件
from django.shortcuts import render
from rest_framework import status
from rest_framework.response import Response
from rest_framework.decorators import api_view
# Create your views here.
@api_view()
def hello_world(request, format=None):
return Response({"message": "Hello, world!"})
http://localhost:8000/login/hello_world/点击网址
得到一个错误
TemplateDoesNotExist at /login/hello_world/
rest_framework/api.html
我想要json格式的数据
【问题讨论】:
标签: python json django django-rest-framework