#9258: Admin ForeignKeyRawIdWidget uses wrong manager for label lookup
---------------------------+------------------------------------------------
 Reporter:  nullie         |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.0       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  1              |  
---------------------------+------------------------------------------------
 It results in exception when trying to edit object which has overriden
 objects managers.

 Here's the patch:

 {{{
 --- django.orig/contrib/admin/widgets.py        2008-09-04
 03:16:05.000000000 +0600
 +++ django/contrib/admin/widgets.py     2008-10-01 12:32:18.000000000
 +0600
 @@ -146,7 +146,7 @@

      def label_for_value(self, value):
          key = self.rel.get_related_field().name
 -        obj = self.rel.to.objects.get(**{key: value})
 +        obj = self.rel.to._default_manager.get(**{key: value})
          return '&nbsp;<strong>%s</strong>' % truncate_words(obj, 14)

  class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9258>
Django <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