#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 antialiasis):
Is there any chance this might be fixed in some way at some point?
Like others, we've been using UUIDs as primary keys on a PostgreSQL
database, and this bug is completely breaking `prefetch_related`. The way
prefetching is implemented (at least in 1.7), instances are collected into
a dictionary with their `to_python`'d primary keys as the keys, and then
it tries to access them using the non-`to_python`'d foreign key ID field.
Needless to say, this results in a KeyError if `to_python` changes the
representation of the field at all (in our case, to strip PostgreSQL's
native hyphens).
--
Ticket URL: <https://code.djangoproject.com/ticket/14518#comment:14>
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.fae3411659284687e6e3822669c40a0f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.