Ticket #14572: 14572.2.diff

File 14572.2.diff, 2.2 KB (added by Preston Timmons, 13 years ago)

Updated patch against r16228

  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    index 81301cf..b025f5a 100644
    a b def generic_inlineformset_factory(model, form=ModelForm,  
    362362                                  fields=None, exclude=None,
    363363                                  extra=3, can_order=False, can_delete=True,
    364364                                  max_num=None,
    365                                   formfield_callback=lambda f: f.formfield()):
     365                                  formfield_callback=None):
    366366    """
    367367    Returns an ``GenericInlineFormSet`` for the given kwargs.
    368368
  • tests/modeltests/generic_relations/tests.py

    diff --git a/tests/modeltests/generic_relations/tests.py b/tests/modeltests/generic_relations/tests.py
    index 3d25301..a2bf3be 100644
    a b  
     1from django import forms
    12from django.contrib.contenttypes.generic import generic_inlineformset_factory
    23from django.contrib.contenttypes.models import ContentType
    34from django.test import TestCase
    class GenericRelationsTests(TestCase):  
    221222        formset = GenericFormSet(instance=lion, prefix='x')
    222223        self.assertEqual(u''.join(form.as_p() for form in formset.forms), u"""<p><label for="id_x-0-tag">Tag:</label> <input id="id_x-0-tag" type="text" name="x-0-tag" maxlength="50" /></p>
    223224<p><label for="id_x-0-DELETE">Delete:</label> <input type="checkbox" name="x-0-DELETE" id="id_x-0-DELETE" /><input type="hidden" name="x-0-id" id="id_x-0-id" /></p>""")
     225
     226
     227class CustomWidget(forms.CharField):
     228    pass
     229
     230class TaggedItemForm(forms.ModelForm):
     231    class Meta:
     232        model = TaggedItem
     233        widgets = {'tag': CustomWidget}
     234
     235class GenericInlineFormsetTest(TestCase):
     236    """
     237    Regression for #14572: Using base forms with widgets
     238    defined in Meta should not raise errors.
     239    """
     240
     241    def test_generic_inlineformset_factory(self):
     242        Formset = generic_inlineformset_factory(TaggedItem, TaggedItemForm)
     243        form = Formset().forms[0]
     244        self.assertTrue(isinstance(form['tag'].field.widget, CustomWidget))
Back to Top