From ffe8994014b891cb50d3ac6a27d8853698dec9c8 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 3 Apr 2009 20:03:46 +0000 Subject: [PATCH] Fixed #10522: accept tuples in `generic_inlineformset_factor(exclude)`. Thanks, mk. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10375 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/contenttypes/generic.py | 1 + tests/regressiontests/generic_inline_admin/tests.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py index 0be1de6e637..adc245bb756 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -355,6 +355,7 @@ def generic_inlineformset_factory(model, form=ModelForm, raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field) fk_field = opts.get_field(fk_field) # let the exception propagate if exclude is not None: + exclude = list(exclude) exclude.extend([ct_field.name, fk_field.name]) else: 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 a3ea5fc60b1..19eab52ae02 100644 --- a/tests/regressiontests/generic_inline_admin/tests.py +++ b/tests/regressiontests/generic_inline_admin/tests.py @@ -2,6 +2,7 @@ from django.test import TestCase from django.conf import settings +from django.contrib.contenttypes.generic import generic_inlineformset_factory # local test models from models import Episode, Media @@ -74,3 +75,8 @@ class GenericAdminViewTest(TestCase): url = '/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk response = self.client.post(url, post_data) self.failUnlessEqual(response.status_code, 302) # redirect somewhere + + def testGenericInlineFormsetFactory(self): + # Regression test for #10522. + inline_formset = generic_inlineformset_factory(Media, + exclude=('url',))