Fixed #827 -- For admin list_display functions without a short_description, 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
This commit is contained in:
Adrian Holovaty 2005-11-17 15:26:50 +00:00
parent 56e40c5884
commit 33ffa72e40
2 changed files with 5 additions and 4 deletions

View File

@ -361,7 +361,7 @@ def change_list(request, app_label, module_name):
try: try:
header = func.short_description header = func.short_description
except AttributeError: except AttributeError:
header = func.__name__ header = func.__name__.replace('_', ' ')
# Non-field list_display values don't get ordering capability. # Non-field list_display values don't get ordering capability.
raw_template.append('<th>%s</th>' % capfirst(header)) raw_template.append('<th>%s</th>' % capfirst(header))
else: else:

View File

@ -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 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 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 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 ``was_published_today`` is, by default, the name of the method (with
change that by giving that method a ``short_description`` attribute:: underscores replaced with spaces). But you can change that by giving that
method a ``short_description`` attribute::
def was_published_today(self): def was_published_today(self):
return self.pub_date.date() == datetime.date.today() 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 Let's add another improvement to the Poll change list page: Filters. Add the