【发布时间】:2013-12-05 06:49:22
【问题描述】:
我可以让 djangorestframework 通过格式后缀 .json 返回 json,但不能通过 .xml 后缀返回 xml
http://127.0.0.1:8000/chat/rooms/.json
[
{
id: 1,
timestamp: "2013-12-05T04:27:42Z",
topic: "important one"
},
{
id: 2,
timestamp: "2013-12-05T04:27:49Z",
topic: "important two"
},
{
id: 3,
timestamp: "2013-12-05T04:27:55Z",
topic: "important three"
},
{
id: 4,
timestamp: "2013-12-05T04:28:01Z",
topic: "important four"
},
{
id: 5,
timestamp: "2013-12-05T06:43:38Z",
topic: "another great stimulating topic"
}
]
http://127.0.0.1:8000/chat/rooms/.xml
{
detail: "Not found"
}
谁能告诉我我做错了什么,b/c REST api 显然在工作......谢谢!
【问题讨论】:
-
有相关代码吗? urls.py 和 view 特别有趣。
标签: python xml django django-rest-framework