Ticket #1054: magic_removal-admin_list_repr_to_str.diff

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

Fix admin_list using __repr__ where it should use __str__

  • db/models/options.py

     
    217217        save_on_top=False, list_select_related=False):
    218218        self.fields = fields
    219219        self.js = js or []
    220         self.list_display = list_display or ['__repr__']
     220        self.list_display = list_display or ['__str__']
    221221        self.list_filter = list_filter or []
    222222        self.date_hierarchy = date_hierarchy
    223223        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