diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 849a774e0a..fd2849ba5e 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -361,7 +361,7 @@ def change_list(request, app_label, module_name): try: header = func.short_description except AttributeError: - header = func.__name__ + header = func.__name__.replace('_', ' ') # Non-field list_display values don't get ordering capability. raw_template.append('<th>%s</th>' % capfirst(header)) else: diff --git a/docs/tutorial02.txt b/docs/tutorial02.txt index 5dc326b1d4..97d9be53b7 100644 --- a/docs/tutorial02.txt +++ b/docs/tutorial02.txt @@ -331,12 +331,13 @@ Now the poll change list page looks like this: You can click on the column headers to sort by those values -- except in the case of the ``was_published_today`` header, because sorting by the output of an arbitrary method is not supported. Also note that the column header for -``was_published_today`` is, by default, the name of the method. But you can -change that by giving that method a ``short_description`` attribute:: +``was_published_today`` is, by default, the name of the method (with +underscores replaced with spaces). But you can change that by giving that +method a ``short_description`` attribute:: def was_published_today(self): return self.pub_date.date() == datetime.date.today() - was_published_today.short_description = 'Was published today' + was_published_today.short_description = 'Published today?' Let's add another improvement to the Poll change list page: Filters. Add the