diff --git a/django/contrib/admin/util.py b/django/contrib/admin/util.py
index 9611b00..224fd86 100644
a
|
b
|
def flatten_fieldsets(fieldsets):
|
87 | 87 | for name, opts in fieldsets: |
88 | 88 | for field in opts['fields']: |
89 | 89 | # type checking feels dirty, but it seems like the best way here |
90 | | if type(field) == tuple: |
| 90 | if isinstance(field, (list, tuple)): |
91 | 91 | field_names.extend(field) |
92 | 92 | else: |
93 | 93 | field_names.append(field) |
diff --git a/tests/regressiontests/admin_util/tests.py b/tests/regressiontests/admin_util/tests.py
index 055f494..08336cf 100644
a
|
b
|
from django.conf import settings
|
6 | 6 | from django.contrib import admin |
7 | 7 | from django.contrib.admin import helpers |
8 | 8 | from django.contrib.admin.util import (display_for_field, label_for_field, |
9 | | lookup_field, NestedObjects) |
| 9 | lookup_field, NestedObjects, flatten_fieldsets) |
10 | 10 | from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE |
11 | 11 | from django.contrib.sites.models import Site |
12 | 12 | from django.db import models, DEFAULT_DB_ALIAS |
… |
… |
class UtilTests(unittest.TestCase):
|
284 | 284 | '<label for="id_text" class="required inline">&text:</label>') |
285 | 285 | self.assertEqual(helpers.AdminField(form, 'cb', is_first=False).label_tag(), |
286 | 286 | '<label for="id_cb" class="vCheckboxLabel required inline">&cb</label>') |
| 287 | |
| 288 | def test_flatten_fieldsets(self): |
| 289 | """ |
| 290 | Regression test for #18051 |
| 291 | """ |
| 292 | fieldsets = ( |
| 293 | (None, { |
| 294 | 'fields': ('url', 'title', ('content', 'sites')) |
| 295 | }), |
| 296 | ) |
| 297 | self.assertEqual(flatten_fieldsets(fieldsets), ['url', 'title', 'content', 'sites']) |
| 298 | |
| 299 | fieldsets = ( |
| 300 | (None, { |
| 301 | 'fields': ('url', 'title', ['content', 'sites']) |
| 302 | }), |
| 303 | ) |
| 304 | self.assertEqual(flatten_fieldsets(fieldsets), ['url', 'title', 'content', 'sites']) |