多个对象创建Tastypie POST XML

时间:2014-01-07 14:28:12

标签: xml django tastypie

我尝试使用HTTP POST请求通过Tastypie和XML格式为模型创建新对象。它适用于一个元素,但每当我尝试创建两个或更多元素时,我都会遇到错误。

AttributeError: 'str' object has no attribute 'items'

'list' object has no attribute 'items'

我的要求如下:

<objects type="list">
  <object>
    <field>'grrrr'</field>
  </object>
  <object>
    <field>'pfff'</field>
  </object>
</objects>

1 个答案:

答案 0 :(得分:1)

要使用tastypie创建多个对象,您应该在列表上下文中使用PATCH方法。

POST中应该同时拥有PATCHlist_allowed_methods。你发送的xml看起来很好(虽然我不熟悉tastypies xml序列化)

来自tastypie的

patch_list method docs