Hi, With a bit of prompting from another Djangoista I've posted the python and json "full" serializer implementations to http://code.djangoproject.com/ticket/4656 .
Please have a try and let me know if you find and bugs or have any other feedback. cheers Matthew On May 6, 4:09 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On May 6, 11:14 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> > wrote: > > > > > On Tue, May 6, 2008 at 8:52 AM, Explore <[EMAIL PROTECTED]> wrote: > > > > Hi. I have been trying to get django to return my models as xml. I > > > have tried using the xml serializer but i cannot get it to send back > > > anything but the initial model. > > > > I would like to get nested xml like below (where Department has a > > > ForeignKey to Organization). > > > That may be what you want, but that's not what the Django serializer > > provides. The original design goal of the Django serializer was to > > allow for the definition of fixtures; output in the format you > > describe only serves to complicate the deserialization process. > > > However, the idea is a good one. What you have requested has been > > suggested before. It is logged as ticket 4656 [1], and has been > > accepted as a feature request. > > > [1]http://code.djangoproject.com/ticket/4656 > > > As I see it, you have two options: > > 1) Write your own custom XML serializer that outputs the format you > > want. Serializers are actually pretty simple to write - it's > > deserializers that cause the most problems, so this probably isn't as > > difficult as you think. > > > 2) Work out a patch to allow this sort of expansion in the Django > > serializers. If a patch (with tests and documentation) were to be > > provided, it would eventually find itself in the trunk. > > > Yours, > > Russ Magee %-) > > I have such a "full" serializer already written for JSON which I > really should have released by now :( . I don't think it would be too > hard to extend it to XML. > > I've written it as an independent python module from the Django > serializers so I can just put this in my settings.py: > > SERIALIZATION_MODULES = { > 'json': 'nong.api.serializers.json', > > } > > It is backwards compatible to a degree, i.e. it accepts all the same > arguments and produces identical output as the Django serializer, but > if you use any of the extra arguments then you'll run into trouble > deserializing as I haven't written that part yet. I discuss how it > works here in this thread [1]. > > Let me get my act together and release it. I'll post an update to the > list soon. > > [1]http://groups.google.com/group/django-users/browse_thread/thread/c930... > > regards > > Matthew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---