Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #827 -- For admin list_display functions without a short_descri…

…ption, Django now converts underscores to spaces. Thanks, Aaron Swartz

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1275 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 33ffa72e40390255df361bfb5f1cee40dc3de508 1 parent 56e40c5
Adrian Holovaty authored November 17, 2005
2  django/contrib/admin/views/main.py
@@ -361,7 +361,7 @@ def change_list(request, app_label, module_name):
361 361
                     try:
362 362
                         header = func.short_description
363 363
                     except AttributeError:
364  
-                        header = func.__name__
  364
+                        header = func.__name__.replace('_', ' ')
365 365
                 # Non-field list_display values don't get ordering capability.
366 366
                 raw_template.append('<th>%s</th>' % capfirst(header))
367 367
             else:
7  docs/tutorial02.txt
@@ -331,12 +331,13 @@ Now the poll change list page looks like this:
331 331
 You can click on the column headers to sort by those values -- except in the
332 332
 case of the ``was_published_today`` header, because sorting by the output of
333 333
 an arbitrary method is not supported. Also note that the column header for
334  
-``was_published_today`` is, by default, the name of the method. But you can
335  
-change that by giving that method a ``short_description`` attribute::
  334
+``was_published_today`` is, by default, the name of the method (with
  335
+underscores replaced with spaces). But you can change that by giving that
  336
+method a ``short_description`` attribute::
336 337
 
337 338
     def was_published_today(self):
338 339
         return self.pub_date.date() == datetime.date.today()
339  
-    was_published_today.short_description = 'Was published today'
  340
+    was_published_today.short_description = 'Published today?'
340 341
 
341 342
 
342 343
 Let's add another improvement to the Poll change list page: Filters. Add the

0 notes on commit 33ffa72

Please sign in to comment.
Something went wrong with that request. Please try again.