Django's serializer has some limitations which makes it a bit of a pain to use. Basically it will ignore any atributes that have been added to a model object.
The code below is for an alternative serializer. This version allows you select what attributes will be serialized on a per object basis. It also allows you to either serialize the data into json or xml. This code also works if you have model instance as an attribute of another model.
You can get the code on django snippets.
The original json encoder was written by Wolfram Kriesing.
Usage:
dumper = DataDumper()
dumper.selectObjectFields('model_class_name',[...fields...])
dumper.selectObjectFields('model_class_name',[...fields...])
dumper.dump(model_instance,'xml')
dumper.dump(model_instance,'json')
dumper.dump(queryset,'xml')




Comments
Barcode Tag Creator
If we lost important messages, contact numbers, music songs, snapshots and videos from iPhone then how can we recover lost data from iPhone?
Term Papers
Thanks for the tip! I've used it on my blog now.
review
Such a nice post, it is really interesting,you are really a hard worker guy, Thanks.
iphone alternative
It's a shame that not many people know that there ARE alternatives to the iphone out there. You can pick up a good iphone alternative for under $100 and even under $50 ! Add to that the fact you can get free apps and you are pretty much laughing all the way to the bank !
Post new comment