From 0b53d318ef29a34afdb4ecca1c50641760a525eb Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 26 Feb 2011 12:43:57 +0000 Subject: [PATCH] Fixed #11447 -- Ensured that ForeignKey widgets in a list-editable admin 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 --- django/contrib/admin/templatetags/admin_list.py | 4 +++- tests/regressiontests/admin_changelist/tests.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 7d4d8cdc98..bbe4b649f5 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -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(' ') diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py index 1f3cb5955a..b53d832752 100644 --- a/tests/regressiontests/admin_changelist/tests.py +++ b/tests/regressiontests/admin_changelist/tests.py @@ -36,7 +36,7 @@ class ChangeListTests(TransactionTestCase): template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}') context = Context({'cl': cl}) table_output = template.render(context) - row_html = 'name(None)' + row_html = 'name(None)' self.assertFalse(table_output.find(row_html) == -1, 'Failed to find expected row element: %s' % table_output) @@ -57,7 +57,7 @@ class ChangeListTests(TransactionTestCase): template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}') context = Context({'cl': cl}) table_output = template.render(context) - row_html = 'nameParent object' + row_html = 'nameParent object' self.assertFalse(table_output.find(row_html) == -1, 'Failed to find expected row element: %s' % table_output)