#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:  0     
        Needs_docs:  0                |   Needs_tests:  0     
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Comment (by Karen Tracey <[EMAIL PROTECTED]>):

 The problem only affects display, the correct value is actually stored in
 the DB.  The admin just doesn't show it correctly.  Given a table for the
 specified model that contains these rows:

 {{{

 +----+---------+-----------+--------------------+
 | id | barcode | parent_id | name               |
 +----+---------+-----------+--------------------+
 |  1 |      86 |      NULL | Apple iMac         |
 |  2 |      22 |      NULL | Lenovo Thinkpad    |
 |  3 |      87 |        86 | Apple Mighty Mouse |
 +----+---------+-----------+--------------------+

 }}}

 The select widget for 'parent' in the change page for "Apple Mighty Mouse"
 will have '-----' selected because no match is found for id=86.  If
 'parent' is listed in `raw_id_fields` the admin will generate an exception
 when it tries to get the object in the table with id=86.  I'll attach a
 patch that fixes both of these, though I'm not very familiar with this
 code so someone with a clue should see if this is even the right place to
 fix things.

 There is some resulting oddness with the `raw_id_fields` case and the
 patch.  For entry, you must enter the pk value of the associated object
 (which is what the magnifying glass lookup will do for you if you use it),
 but when you hit "Save and continue editing" that value will be
 transformed to the to_field value for the entered pk.  This could be
 somewhat confusing and lead people to think they need to enter the
 to_field values, which won't work properly.

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