Hi,

I want to subclass a db field (CharField), but in the to_python()
method I need the value (which is given) and the model instance (which is 
missing).

I looked at the source of django/db/models/fields/subclassing.py:
http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/subclassing.py

Unfortunately, it seems difficult to alter the Creator class. I could copy the 
whole
file and modify the code, but that's not a good solution. But I guess I will go
this way, since I don't want to run a modified django version.

Is someone interested in a patch which modifies subclassing.py to
make this possible?

# Finally that's what I need for my db field:
class Creator(object):
    ...
    def __set__(self, obj, value):
        obj.__dict__[self.field.name] = self.field.to_python(value, obj)

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to