diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 40c3336..a8f5de9 100644
a
|
b
|
from django.forms import ModelForm
|
12 | 12 | from django.forms.models import BaseModelFormSet, modelformset_factory, save_instance |
13 | 13 | from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets |
14 | 14 | from django.utils.encoding import smart_unicode |
| 15 | from django.utils.functional import curry |
15 | 16 | |
16 | 17 | class GenericForeignKey(object): |
17 | 18 | """ |
… |
… |
class GenericInlineModelAdmin(InlineModelAdmin):
|
391 | 392 | "ct_field": self.ct_field, |
392 | 393 | "fk_field": self.ct_fk_field, |
393 | 394 | "form": self.form, |
394 | | "formfield_callback": self.formfield_for_dbfield, |
| 395 | "formfield_callback": curry(self.formfield_for_dbfield, request=request), |
395 | 396 | "formset": self.formset, |
396 | 397 | "extra": self.extra, |
397 | 398 | "can_delete": self.can_delete, |
diff --git a/tests/regressiontests/generic_inline_admin/models.py b/tests/regressiontests/generic_inline_admin/models.py
index 329c487..144d4ab 100644
a
|
b
|
class MediaPermanentInline(generic.GenericTabularInline):
|
106 | 106 | can_delete = False |
107 | 107 | |
108 | 108 | admin.site.register(EpisodePermanent, inlines=[MediaPermanentInline]) |
| 109 | |
| 110 | |
| 111 | # |
| 112 | # Generic inline with additional model |
| 113 | # |
| 114 | |
| 115 | class ModelC(models.Model): |
| 116 | relation_b = models.ForeignKey('ModelB') |
| 117 | |
| 118 | tagged_object = generic.GenericForeignKey() |
| 119 | content_type = models.ForeignKey(ContentType) |
| 120 | object_id = models.PositiveIntegerField() |
| 121 | |
| 122 | class ModelA(models.Model): |
| 123 | pass |
| 124 | |
| 125 | class ModelB(models.Model): |
| 126 | pass |
| 127 | |
| 128 | |
| 129 | class ModelCInline(generic.GenericTabularInline): |
| 130 | model = ModelC |
| 131 | |
| 132 | |
| 133 | class ModelAAdmin(admin.ModelAdmin): |
| 134 | inlines = [ModelCInline] |
| 135 | |
| 136 | admin.site.register(ModelA, ModelAAdmin) |
| 137 | admin.site.register(ModelB) |
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index 0626699..6b32761 100644
a
|
b
|
class GenericInlineAdminWithUniqueTogetherTest(TestCase):
|
203 | 203 | response = self.client.post('/generic_inline_admin/admin/generic_inline_admin/contact/add/', post_data) |
204 | 204 | self.failUnlessEqual(response.status_code, 302) # redirect somewhere |
205 | 205 | |
| 206 | class GenericInlineAdminWithForeignKeyTest(TestCase): |
| 207 | fixtures = ['users.xml'] |
| 208 | |
| 209 | def setUp(self): |
| 210 | self.client.login(username='super', password='secret') |
| 211 | |
| 212 | def tearDown(self): |
| 213 | self.client.logout() |
| 214 | |
| 215 | def testBasicAddGet(self): |
| 216 | """ |
| 217 | Regression test for #14283 |
| 218 | """ |
| 219 | |
| 220 | response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/modela/add/') |
| 221 | self.failUnlessEqual(response.status_code, 200) |
| 222 | |
206 | 223 | class NoInlineDeletionTest(TestCase): |
207 | 224 | def test_no_deletion(self): |
208 | 225 | fake_site = object() |