Ticket #10522: 10522.patch

File 10522.patch, 3.3 KB (added by Matthias Kestenholz, 16 years ago)
  • django/contrib/contenttypes/generic.py

    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,  
    353353        raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field)
    354354    fk_field = opts.get_field(fk_field) # let the exception propagate
    355355    if exclude is not None:
     356        exclude = list(exclude)
    356357        exclude.extend([ct_field.name, fk_field.name])
    357358    else:
    358359        exclude = [ct_field.name, fk_field.name]
  • tests/regressiontests/generic_inline_admin/tests.py

    diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
    index a3ea5fc..efa9ed3 100644
    a b  
    22
    33from django.test import TestCase
    44from django.conf import settings
     5from django.contrib.contenttypes.generic import generic_inlineformset_factory
    56
    67# local test models
    78from models import Episode, Media
    class GenericAdminViewTest(TestCase):  
    1617        self.original_template_debug = settings.TEMPLATE_DEBUG
    1718        settings.TEMPLATE_DEBUG = True
    1819        self.client.login(username='super', password='secret')
    19        
     20
    2021        # Can't load content via a fixture (since the GenericForeignKey
    2122        # relies on content type IDs, which will vary depending on what
    2223        # other tests have been run), thus we do it here.
    class GenericAdminViewTest(TestCase):  
    2526        m = Media(content_object=e, url='http://example.com/podcast.mp3')
    2627        m.save()
    2728        self.media_pk = m.pk
    28    
     29
    2930    def tearDown(self):
    3031        self.client.logout()
    3132        settings.TEMPLATE_DEBUG = self.original_template_debug
    32    
     33
    3334    def testBasicAddGet(self):
    3435        """
    3536        A smoke test to ensure GET on the add_view works.
    3637        """
    3738        response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/add/')
    3839        self.failUnlessEqual(response.status_code, 200)
    39    
     40
    4041    def testBasicEditGet(self):
    4142        """
    4243        A smoke test to ensure GET on the change_view works.
    4344        """
    4445        response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk)
    4546        self.failUnlessEqual(response.status_code, 200)
    46    
     47
    4748    def testBasicAddPost(self):
    4849        """
    4950        A smoke test to ensure POST on add_view works.
    class GenericAdminViewTest(TestCase):  
    5657        }
    5758        response = self.client.post('/generic_inline_admin/admin/generic_inline_admin/episode/add/', post_data)
    5859        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
    59    
     60
    6061    def testBasicEditPost(self):
    6162        """
    6263        A smoke test to ensure POST on edit_view works.
    class GenericAdminViewTest(TestCase):  
    7475        url = '/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk
    7576        response = self.client.post(url, post_data)
    7677        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',))
Back to Top