Ticket #1326: list_display_properties_r2265.diff
File list_display_properties_r2265.diff, 2.8 KB (added by , 19 years ago) |
---|
-
django/core/management.py
889 889 try: 890 890 f = opts.get_field(fn) 891 891 except models.FieldDoesNotExist: 892 if not hasattr(cls, fn) or not callable(getattr(cls, fn)):893 e.add(opts, '"admin.list_display" refers to %r, which isn\'t a field or method.' % fn)892 if not hasattr(cls, fn): 893 e.add(opts, '"admin.list_display" refers to %r, which isn\'t a field, attribute, method, or property.' % fn) 894 894 else: 895 895 if isinstance(f, models.ManyToManyField): 896 896 e.add(opts, '"admin.list_display" doesn\'t support ManyToManyFields (%r).' % fn) -
django/contrib/admin/templatetags/admin_list.py
80 80 if field_name == '__repr__': 81 81 header = lookup_opts.verbose_name 82 82 else: 83 func= getattr(cl.model, field_name) # Let AttributeErrors propogate.83 attr = getattr(cl.model, field_name) # Let AttributeErrors propogate. 84 84 try: 85 header = func.short_description85 header = attr.short_description 86 86 except AttributeError: 87 header = f unc.__name__.replace('_', ' ')87 header = field_name.replace('_', ' ') 88 88 # Non-field list_display values don't get ordering capability. 89 89 yield {"text": header} 90 90 else: … … 113 113 # For non-field list_display values, the value is a method 114 114 # name. Execute the method. 115 115 try: 116 func = getattr(result, field_name) 117 result_repr = str(func()) 116 attr = getattr(result, field_name) 117 if callable(attr): 118 attr = attr() 119 result_repr = str(attr) 118 120 except AttributeError, ObjectDoesNotExist: 119 121 result_repr = EMPTY_CHANGELIST_VALUE 120 122 else: 121 123 # Strip HTML tags in the resulting text, except if the 122 124 # function has an "allow_tags" attribute set to True. 123 if not getattr( func, 'allow_tags', False):125 if not getattr(attr, 'allow_tags', False): 124 126 result_repr = escape(result_repr) 125 127 else: 126 128 field_val = getattr(result, f.attname)