2014-02-09 26 views
0

我有一個模型資源,它返回一個外鍵列表。 當連載到XML Tastypie創建如下:在Django中對XML進行自定義反序列化Tastypie

<object> 
    <friends type='list'> 
     <object>....</object> 
     <object>....</object> 
     <object>....</object>  
</object> 

然而,當我上傳到我的服務器從客戶端我寧願發送以下XML

<object> 
    <friends> 
     <friend>....</friend> 
     <friend>....</friend> 
     <friend>....</friend> 
    </friends> 
</object> 

我想我有我自己寫的串行器並改變串行器的行爲,但我希望有一個更簡單的解決方案。

感謝您的幫助提前

回答

0

我結束了一個定製的解決方案,使用lxml.etree來管理我的迴應的數據結構。我認爲Tastypie支持XML。您可以接受數據序列化/反序列化的方式,也可以編寫自己的entry_points。使用內置的django模板引擎證明是有用的。