Re: Subclassing the ForeignKey field type

2011-10-24 Thread Tobia Conforto
Hi Guy I do think my approach is better. Remember the Django motto "Don't Repeat Yourself"! The serialization logic belongs to a library class, not in your models. I can't give you my entire code (it belongs to my employer) but I can point you to the right direction. -Tobia # your model: class

Re: Subclassing the ForeignKey field type

2011-10-24 Thread guyf
Hi Tobia, I have just discovered your post and I am trying to do something very similar (create and XML doc from an object hierarchy). I have started by trying to use the @toxml decorator and override the __serialize__ method on my model. See (partially working) code below. @toxml class

Re: Subclassing the ForeignKey field type

2011-09-28 Thread Tobia Conforto
Konk wrote: > As for what you are doing, I don't think subclassing ForeignKeys is > the way to go. Currently they defer most of the work to their target > fields, you might try to do something similar with the features you're > trying to add. Problem solved: I just didn't have to put

Re: Subclassing the ForeignKey field type

2011-09-19 Thread Michal Petrucha
On Thu, Sep 15, 2011 at 09:43:57AM -0700, Tobia Conforto wrote: > Hi all > > I'm adding an XML mapping feature to Django db models. > > The idea is to add as little XML mapping information as possible to existing > models (such as: which fields get mapped to XML, what is their XPath...) in >

Subclassing the ForeignKey field type

2011-09-15 Thread Tobia Conforto
Hi all I'm adding an XML mapping feature to Django db models. The idea is to add as little XML mapping information as possible to existing models (such as: which fields get mapped to XML, what is their XPath...) in order to be able to automatically: 1. produce an XML representation of an