#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):

 Yeah, I agree fixing it at the widget level seems not quite the right
 place.  It'd be better to have a fix in one place, that works regardless
 of the widget.  Only...I don't know where that place is.  It's the widget
 (or, at any rate the admin widgets) that have saved a reference to the
 actual related field which includes the name of `to_field`, and it is the
 widget that gets handed the current value to render.  That value is
 currently the value stored in the database for the field, and it needs to
 be translated to a PK value for things to work right.

 Now there is code somewhere for the "saving" case that takes a PK value
 and translates it to the `to_field` value for actual saving in the DB.  It
 would seem to be a good symmetrical solution to have the transformation in
 the other direction done at the same 'level', only I'm not sure where that
 is.  I think it is somewhere in django/db/models/fields/related.py that's
 doing the transform for the setting case.  Maybe the corresponding get
 code isn't being called when it should be to transform the DB value from
 the `to_field` value to pk value?  But reading through that code it's a
 bit mysterious to me, and I fear I had too much sun today and not enough
 sleep last night to puzzle through it right now....

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8648#comment:8>
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to