Ticket #1054: magic_removal-admin_list_repr_to_str-2.diff

File magic_removal-admin_list_repr_to_str-2.diff, 1.4 KB (added by Tom Tobin <korpios@…>, 19 years ago)

Fix admin_list using __repr__ where it should use __str__ (fresh for recent changes)

  • db/models/options.py

     
    209209        save_on_top=False, list_select_related=False):
    210210        self.fields = fields
    211211        self.js = js or []
    212         self.list_display = list_display or ['__repr__']
     212        self.list_display = list_display or ['__str__']
    213213        self.list_filter = list_filter or []
    214214        self.date_hierarchy = date_hierarchy
    215215        self.save_as, self.ordering = save_as, ordering
  • contrib/admin/templatetags/admin_list.py

     
    7676        except models.FieldDoesNotExist:
    7777            # For non-field list_display values, check for the function
    7878            # attribute "short_description". If that doesn't exist, fall
    79             # back to the method name. And __repr__ is a special-case.
    80             if field_name == '__repr__':
     79            # back to the method name. And __str__ is a special-case.
     80            if field_name == '__str__':
    8181                header = lookup_opts.verbose_name
    8282            else:
    8383                func = getattr(cl.model, field_name) # Let AttributeErrors propogate.
Back to Top