ok, I made this change to the Model.__init__() method. at the very end:

        for i, arg in enumerate(args):
+           if hasattr(self._meta.fields[i], 'translate_from_db') and arg:
+               arg = self._meta.fields[i].translate_from_db(arg)
            setattr(self, self._meta.fields[i].attname, arg)

this just checks to see if the field has a method to translate the value.
In my case, I use it to change the value from
'0101000020732000000000000000003E400000000000003E40' to (30.0, 30.0) which
I think is much nicer.

So, is this something that could reasonably be put into Django? It would
allow me (and others) to add more complex custom fields without having to
modify the Django core code.

--B


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to