diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 8dd735d..78e102a 100644
a
|
b
|
def generic_inlineformset_factory(model, form=ModelForm,
|
353 | 353 | raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field) |
354 | 354 | fk_field = opts.get_field(fk_field) # let the exception propagate |
355 | 355 | if exclude is not None: |
| 356 | exclude = list(exclude) |
356 | 357 | exclude.extend([ct_field.name, fk_field.name]) |
357 | 358 | else: |
358 | 359 | exclude = [ct_field.name, fk_field.name] |
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index a3ea5fc..efa9ed3 100644
a
|
b
|
|
2 | 2 | |
3 | 3 | from django.test import TestCase |
4 | 4 | from django.conf import settings |
| 5 | from django.contrib.contenttypes.generic import generic_inlineformset_factory |
5 | 6 | |
6 | 7 | # local test models |
7 | 8 | from models import Episode, Media |
… |
… |
class GenericAdminViewTest(TestCase):
|
16 | 17 | self.original_template_debug = settings.TEMPLATE_DEBUG |
17 | 18 | settings.TEMPLATE_DEBUG = True |
18 | 19 | self.client.login(username='super', password='secret') |
19 | | |
| 20 | |
20 | 21 | # Can't load content via a fixture (since the GenericForeignKey |
21 | 22 | # relies on content type IDs, which will vary depending on what |
22 | 23 | # other tests have been run), thus we do it here. |
… |
… |
class GenericAdminViewTest(TestCase):
|
25 | 26 | m = Media(content_object=e, url='http://example.com/podcast.mp3') |
26 | 27 | m.save() |
27 | 28 | self.media_pk = m.pk |
28 | | |
| 29 | |
29 | 30 | def tearDown(self): |
30 | 31 | self.client.logout() |
31 | 32 | settings.TEMPLATE_DEBUG = self.original_template_debug |
32 | | |
| 33 | |
33 | 34 | def testBasicAddGet(self): |
34 | 35 | """ |
35 | 36 | A smoke test to ensure GET on the add_view works. |
36 | 37 | """ |
37 | 38 | response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/add/') |
38 | 39 | self.failUnlessEqual(response.status_code, 200) |
39 | | |
| 40 | |
40 | 41 | def testBasicEditGet(self): |
41 | 42 | """ |
42 | 43 | A smoke test to ensure GET on the change_view works. |
43 | 44 | """ |
44 | 45 | response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk) |
45 | 46 | self.failUnlessEqual(response.status_code, 200) |
46 | | |
| 47 | |
47 | 48 | def testBasicAddPost(self): |
48 | 49 | """ |
49 | 50 | A smoke test to ensure POST on add_view works. |
… |
… |
class GenericAdminViewTest(TestCase):
|
56 | 57 | } |
57 | 58 | response = self.client.post('/generic_inline_admin/admin/generic_inline_admin/episode/add/', post_data) |
58 | 59 | self.failUnlessEqual(response.status_code, 302) # redirect somewhere |
59 | | |
| 60 | |
60 | 61 | def testBasicEditPost(self): |
61 | 62 | """ |
62 | 63 | A smoke test to ensure POST on edit_view works. |
… |
… |
class GenericAdminViewTest(TestCase):
|
74 | 75 | url = '/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk |
75 | 76 | response = self.client.post(url, post_data) |
76 | 77 | self.failUnlessEqual(response.status_code, 302) # redirect somewhere |
| 78 | |
| 79 | def testGenericInlineFormsetFactory(self): |
| 80 | # Regression test for #10522. |
| 81 | inline_formset = generic_inlineformset_factory(Media, |
| 82 | exclude=('url',)) |