diff --git a/tests/regressiontests/inline_formsets/forms.py b/tests/regressiontests/inline_formsets/forms.py
new file mode 100644
index 0000000..e7d752f
-
|
+
|
|
| 1 | from django import forms |
| 2 | |
| 3 | from regressiontests.inline_formsets.models import Poem |
| 4 | |
| 5 | |
| 6 | class PoemModelForm(forms.ModelForm): |
| 7 | class Meta: |
| 8 | model = Poem |
diff --git a/tests/regressiontests/inline_formsets/tests.py b/tests/regressiontests/inline_formsets/tests.py
index 5bd9d18..76d087b 100644
a
|
b
|
|
1 | 1 | from django.forms.models import inlineformset_factory |
2 | 2 | from django.test import TestCase |
3 | 3 | |
| 4 | from regressiontests.inline_formsets.forms import PoemModelForm |
4 | 5 | from regressiontests.inline_formsets.models import Poet, Poem, School, Parent, Child |
5 | 6 | |
6 | 7 | |
… |
… |
class InlineFormsetFactoryTest(TestCase):
|
154 | 155 | inlineformset_factory( |
155 | 156 | Parent, Child, exclude=('school',), fk_name='mother' |
156 | 157 | ) |
| 158 | |
| 159 | |
| 160 | class FormOverrideTestCase(TestCase): |
| 161 | def test_overrides_intact(self): |
| 162 | emily = Poet.objects.create(name='Emily Dickinson') |
| 163 | edgar = Poet.objects.create(name='Edgar Allan Poe') |
| 164 | |
| 165 | # override the queryset |
| 166 | PoemModelForm.base_fields['poet'].queryset = Poet.objects.filter( |
| 167 | name='Emily Dickinson' |
| 168 | ) |
| 169 | |
| 170 | # send our form in |
| 171 | formset = inlineformset_factory( |
| 172 | Poet, Poem, form=PoemModelForm, extra=1 |
| 173 | ) |
| 174 | |
| 175 | self.assertEqual(list(formset.form.base_fields['poet'].queryset), [emily]) |