Ticket #2301: django.admin.list_display_links.patch
File django.admin.list_display_links.patch, 3.3 KB (added by , 18 years ago) |
---|
-
django/db/models/options.py
199 199 return self._field_types[field_type] 200 200 201 201 class AdminOptions(object): 202 def __init__(self, fields=None, js=None, list_display=None, list_ filter=None,202 def __init__(self, fields=None, js=None, list_display=None, list_display_links=None, list_filter=None, 203 203 date_hierarchy=None, save_as=False, ordering=None, search_fields=None, 204 204 save_on_top=False, list_select_related=False, manager=None, list_per_page=100): 205 205 self.fields = fields 206 206 self.js = js or [] 207 207 self.list_display = list_display or ['__str__'] 208 self.list_display_links = list_display_links or [] 208 209 self.list_filter = list_filter or [] 209 210 self.date_hierarchy = date_hierarchy 210 211 self.save_as, self.ordering = save_as, ordering -
django/core/management.py
936 936 else: 937 937 if isinstance(f, models.ManyToManyField): 938 938 e.add(opts, '"admin.list_display" doesn\'t support ManyToManyFields (%r).' % fn) 939 # list_display_links 940 if opts.admin.list_display_links and not opts.admin.list_display: 941 e.add(opts, '"admin.list_display" must be defined for "admin.list_display_links" to be used.') 942 if not isinstance(opts.admin.list_display_links, (list, tuple)): 943 e.add(opts, '"admin.list_display_links", if given, must be set to a list or tuple.') 944 else: 945 for fn in opts.admin.list_display_links: 946 try: 947 f = opts.get_field(fn) 948 except models.FieldDoesNotExist: 949 e.add(opts, '"admin.list_filter" refers to %r, which isn\'t a field.' % fn) 950 if fn not in opts.admin.list_display: 951 e.add(opts, '"admin.list_display_links" refers to %r, which is not defined in "admin.list_display".' % fn) 939 952 # list_filter 940 953 if not isinstance(opts.admin.list_filter, (list, tuple)): 941 954 e.add(opts, '"admin.list_filter", if given, must be set to a list or tuple.') -
django/contrib/admin/templatetags/admin_list.py
165 165 result_repr = escape(str(field_val)) 166 166 if result_repr == '': 167 167 result_repr = ' ' 168 if first: # First column is a special case 168 # If list_display_links not defined, add the link tag to the first field 169 if (first and not cl.lookup_opts.admin.list_display_links) or field_name in cl.lookup_opts.admin.list_display_links: 169 170 first = False 170 171 url = cl.url_for_result(result) 171 172 result_id = str(getattr(result, pk)) # str() is needed in case of 23L (long ints)