#8648: Admin ignores to_field on ForeignKey
--------------------------------------+-------------------------------------
Reporter: kmtracey | Owner: nobody
Status: new | Milestone: 1.0
Component: Admin interface | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Comment (by kmtracey):
Ah, OK. Yes, with .3 now the display is correct for the raw_id_fields
case. But...the magnifying-glass icon can't be used to select a new value,
because it returns the PK value. If you use the magnifying-glass icon to
select a different related object, it fills in the PK value for the object
you choose, not the `to_field` value. This, I fear, will lead to an
incorrect relation being saved in the case where the PK values overlap the
`to_field` values.
In cases where they don't, when you select any of the save alternatives
you get the same traceback as before (except the code in admin/widgets.py
is now `obj = self.rel.to.objects.get(**{key: value})`). The admin is
actually attempting to re-display the form with an error message "Select a
valid choice. That choice is not one of the available choices." but the
invalid value in the raw select widget leads to an exception. This is
actually a problem independent of this ticket (I can recreate it by just
typing in an out-of-range PK value in a raw_id field that has no
`to_field` specified) so this part may belong in a new ticket.
But the fact that choosing a new related object by using the looking glass
icon results in a PK value, not a `to_field` value, being filled in for
the field needs to be solved along with the rest of the `to_field` stuff,
I think.
--
Ticket URL: <http://code.djangoproject.com/ticket/8648#comment:14>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---