自定义序列化选项

自定义序列化选项

本文介绍了Django:自定义序列化选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于Django的网络服务,我正在努力找出最好的方法来做我的序列化。



要求是,我想要对响应中包含的格式和字段有完全的控制。



例如,Django序列化器不幸的是,它包含 )自动包装在 {model:app.Model,pk:42,fields:{...}} 中的字段,这对于创建装配是非常好的,但isn对我来说很好 - 我想完全控制输出。



此外,我想要一个知道Django对象的串行化器,例如,它将使用 QuerySet ManyToManyField



目前我正在考虑使用django-piston的,但是我对django-piston的经验只是平庸,所以我'我想看看是否还有其他选项。



那么,还有其他可定制的Django序列化程序的选项吗?


解决方案

编辑:

p>

现在在






我正在为Django编写一个功能齐全的序列化框架。目的是完全控制序列化。它可能会很好地填写你的要求!但是,还没有准备好我估计在1或2周内我可以发布第一个版本。



您仍然可以检查google代码:,甚至如果您有兴趣,请提供一些帮助



第一个版本将会出现在精选下载!


I'm working on a Django-based web service and I'm trying to figure out what the best way to do my serialization will be.

The tricky requirement, though, is that I'd like to have pretty much full control over format of, and fields contained in, the response.

For example, the Django serializers (which, unfortunately, includes the wadofstuff serializer) automatically wrap the fields in { model: "app.Model", pk: 42, fields: { ... }}, which is great for creating fixtures, but isn't great for me — I'd like full control over the output.

Additionally, I'd like a serializer that is aware of Django's objects so, for example, it will do the Right Thing with a QuerySet or ManyToManyField.

Currently I'm thinking of using django-piston's emitters.py, but my experience with django-piston has only been mediocreª, so I'd like to see if there are other options.

So, are there any other options for customizable Django serializers?

ª: It's sparsely documented and tested, and I've had some problems with the serializer.

解决方案

EDIT :

Now out at https://bitbucket.org/sebpiq/any2any/


I am currently writing a full-featured serialization framework for Django. The aim is precisely to have full control over the serialization. It would probably fill-in your requirements pretty well ! However, it is not ready yet. I estimate that in 1 or 2 weeks I will be able to release a first version.

You can still check the google code : http://code.google.com/p/django-serializable/ , even give some help if you are interested in it.

There will be a featured download when the first release will be out !

这篇关于Django:自定义序列化选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 14:16