#14518: Field.to_python not called on foreign key IDs
-------------------------------------+-------------------------------------
Reporter: wolever | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by anubhav9042):
Thanks for your explanation. As I said my patch wasn't correct, it only
was to tell which line caused errors.
Now that I tried the following:
{{{
def to_python(self, value):
return ".".join(value)
}}}
So the lookup which failed earlier passes, but as explained by Harm above,
{{{
>>> m2.foo_id
u'a...n...u...b...h...a...v'
>>> m2.foo.field
u'a.......n.......u.......b.......h.......a.......v'
}}}
But it should have been: `u'a.n.u.b.h.a.v'`
It seems that `to_python` is called too many times and that might be wrong
when it is defined in a way like in my examples..
Also if we remove `__metaclass__ = models.SubfieldBase` from our custom
field then `to_python` does gets called but something strange happens as
it appears it does not serves the purpose as always `u'anubhav'` is
returned by `m1.field` or `m2.foo_id`.
There might be problem in that metaclass implementation, but thats just a
wild guess.
--
Ticket URL: <https://code.djangoproject.com/ticket/14518#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.56e8b961ff494c7c434e379f91c714cb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.