Fixed #954 -- Many-to-many raw_id_admin change page now displays original object(s) correctly. Thanks for reporting, mordaha

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1489 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-11-29 05:54:56 +00:00
parent 29d1598cce
commit 2af63d3aab
1 changed files with 6 additions and 7 deletions

View File

@ -276,10 +276,9 @@ def get_javascript_imports(opts,auto_populated_fields, ordered_objects, field_se
break break
return js return js
class AdminBoundField(BoundField): class AdminBoundField(BoundField):
def __init__(self, field, field_mapping, original): def __init__(self, field, field_mapping, original):
super(AdminBoundField, self).__init__(field,field_mapping,original) super(AdminBoundField, self).__init__(field, field_mapping, original)
self.element_id = self.form_fields[0].get_id() self.element_id = self.form_fields[0].get_id()
self.has_label_first = not isinstance(self.field, meta.BooleanField) self.has_label_first = not isinstance(self.field, meta.BooleanField)
@ -291,7 +290,7 @@ class AdminBoundField(BoundField):
self.first = False self.first = False
classes = [] classes = []
if(self.raw_id_admin): if self.raw_id_admin:
classes.append('nowrap') classes.append('nowrap')
if max([bool(f.errors()) for f in self.form_fields]): if max([bool(f.errors()) for f in self.form_fields]):
classes.append('error') classes.append('error')
@ -305,15 +304,15 @@ class AdminBoundField(BoundField):
return func(self.original) return func(self.original)
def _fill_existing_display(self): def _fill_existing_display(self):
if self._display_filled: if getattr(self, '_display_filled', False):
return return
#HACK # HACK
if isinstance(self.field.rel, meta.ManyToOne): if isinstance(self.field.rel, meta.ManyToOne):
func_name = 'get_%s' % self.field.name func_name = 'get_%s' % self.field.name
self._display = self._fetch_existing_display(func_name) self._display = self._fetch_existing_display(func_name)
elif isinstance(self.field.rel, meta.ManyToMany): elif isinstance(self.field.rel, meta.ManyToMany):
func_name = 'get_%s_list' % self.field.name func_name = 'get_%s_list' % self.field.rel.singular
self._display = ",".join(self._fetch_existing_display(func_name)) self._display = ", ".join([str(obj) for obj in self._fetch_existing_display(func_name)])
self._display_filled = True self._display_filled = True
def existing_display(self): def existing_display(self):