Skip to content

Commit

Permalink
Fixed #11447 -- Ensured that ForeignKey widgets in a list-editable ad…
Browse files Browse the repository at this point in the history
…min changelist won't wrap split the widget. Thanks to patrick@vonautomatisch.at for the report, and Julien Phalip for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15656 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Feb 26, 2011
1 parent e5dfc6c commit 0b53d31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion django/contrib/admin/templatetags/admin_list.py
Expand Up @@ -163,7 +163,9 @@ def items_for_result(cl, result, form):
result_repr = escape(field_val)
else:
result_repr = display_for_field(value, f)
if isinstance(f, models.DateField) or isinstance(f, models.TimeField):
if isinstance(f, models.DateField)\
or isinstance(f, models.TimeField)\
or isinstance(f, models.ForeignKey):
row_class = ' class="nowrap"'
if force_unicode(result_repr) == '':
result_repr = mark_safe(' ')
Expand Down
4 changes: 2 additions & 2 deletions tests/regressiontests/admin_changelist/tests.py
Expand Up @@ -36,7 +36,7 @@ def test_result_list_empty_changelist_value(self):
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
context = Context({'cl': cl})
table_output = template.render(context)
row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th><a href="1/">name</a></th><td>(None)</td></tr></tbody>'
row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th><a href="1/">name</a></th><td class="nowrap">(None)</td></tr></tbody>'
self.assertFalse(table_output.find(row_html) == -1,
'Failed to find expected row element: %s' % table_output)

Expand All @@ -57,7 +57,7 @@ def test_result_list_html(self):
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
context = Context({'cl': cl})
table_output = template.render(context)
row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th><a href="1/">name</a></th><td>Parent object</td></tr></tbody>'
row_html = '<tbody><tr class="row1"><td class="action-checkbox"><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th><a href="1/">name</a></th><td class="nowrap">Parent object</td></tr></tbody>'
self.assertFalse(table_output.find(row_html) == -1,
'Failed to find expected row element: %s' % table_output)

Expand Down

0 comments on commit 0b53d31

Please sign in to comment.