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

 I still get the same exception in the raw_id_fields case, even with
 8648.2.diff.  I did apply the right fix because the new test fails:

 {{{
 ======================================================================
 FAIL: Doctest: regressiontests.admin_widgets.models.__test__.WIDGETS_TESTS
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "D:\u\kmt\django\trunk\django\test\_doctest.py", line 2180, in
 runTest
     raise self.failureException(self.format_failure(new.getvalue()))
 AssertionError: Failed doctest test for
 regressiontests.admin_widgets.models.__test__.WIDGETS_TESTS
   File
 "D:\u\kmt\django\trunk\tests\regressiontests\admin_widgets\models.py",
 line unknown line number, in WIDGETS_TESTS


 ----------------------------------------------------------------------
 File
 "D:\u\kmt\django\trunk\tests\regressiontests\admin_widgets\models.py",
 line ?, in regressiontests.admin_widgets.mod
 els.__test__.WIDGETS_TESTS
 Failed example:
     print w.render('test', core.parent_id, attrs={})
 Exception raised:
     Traceback (most recent call last):
       File "D:\u\kmt\django\trunk\django\test\_doctest.py", line 1267, in
 __run
         compileflags, 1) in test.globs
       File "<doctest
 regressiontests.admin_widgets.models.__test__.WIDGETS_TESTS[35]>", line 1,
 in <module>
         print w.render('test', core.parent_id, attrs={})
       File "d:\u\kmt\django\trunk\django\contrib\admin\widgets.py", line
 122, in render
         output.append(self.label_for_value(value))
       File "d:\u\kmt\django\trunk\django\contrib\admin\widgets.py", line
 127, in label_for_value
         truncate_words(self.rel.to.objects.get(pk=value), 14)
       File "d:\u\kmt\django\trunk\django\db\models\manager.py", line 81,
 in get
         return self.get_query_set().get(*args, **kwargs)
       File "d:\u\kmt\django\trunk\django\db\models\query.py", line 301, in
 get
         % self.model._meta.object_name)
     DoesNotExist: Inventory matching query does not exist.


 ----------------------------------------------------------------------
 Ran 1 test in 0.070s

 FAILED (failures=1)
 Destroying test database...

 }}}

 The ForeignKeyRawIDWidget is assuming that `value` is a PK value here:

 {{{
     def label_for_value(self, value):
         return '&nbsp;<strong>%s</strong>' % \
             truncate_words(self.rel.to.objects.get(pk=value), 14)
 }}}

 So I see the test for this case but not the fix?

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