我从文档中读到支持 XML 格式 http://django-tastypie.readthedocs.org/en/latest/serialization.html#to-xml,但是在当前任务中,我只需要输入http://url/浏览器中的api/entry/?format=json,并在URL.py中定义对应的url和入口资源,json的序列化处理得很好。但是对于 xml,还有额外的事情要做,因为我似乎找不到有用的例子?
#urls.py
entry_resource = EntryResource()
urlpatterns = patterns('',
url(r'^api/', include(entry_resource.urls)),
)
#entry class
class EntryResource(Resource):
....
....fields
class Meta:
resource_name = 'entry'
object_class = Entry
....