Commits

jez...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed cb4a6ee

Fixed #14670 -- Made GenericTabularInline aware of changes made in r13708. Thanks, gregmuellegger.

  • Participants
  • Parent commits 5bf4017

Comments (0)

Files changed (3)

File django/contrib/contenttypes/generic.py

 from django.forms.models import BaseModelFormSet, modelformset_factory, save_instance
 from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets
 from django.utils.encoding import smart_unicode
+from django.utils.functional import curry
 
 from django.contrib.contenttypes.models import ContentType
 
             "ct_field": self.ct_field,
             "fk_field": self.ct_fk_field,
             "form": self.form,
-            "formfield_callback": self.formfield_for_dbfield,
+            "formfield_callback": curry(self.formfield_for_dbfield, request=request),
             "formset": self.formset,
             "extra": self.extra,
             "can_delete": self.can_delete,

File tests/regressiontests/generic_inline_admin/models.py

 # Generic inline with unique_together
 #
 
+class Category(models.Model):
+    name = models.CharField(max_length=50)
+
 class PhoneNumber(models.Model):
     content_type = models.ForeignKey(ContentType)
     object_id = models.PositiveIntegerField()
     content_object = generic.GenericForeignKey('content_type', 'object_id')
     phone_number = models.CharField(max_length=30)
+    category = models.ForeignKey(Category, null=True, blank=True)
 
     class Meta:
         unique_together = (('content_type', 'object_id', 'phone_number',),)
     model = PhoneNumber
 
 admin.site.register(Contact, inlines=[PhoneNumberInline])
+admin.site.register(Category)
 
 #
 # Generic inline with can_delete=False

File tests/regressiontests/generic_inline_admin/tests.py

 
 # local test models
 from models import Episode, EpisodeExtra, EpisodeMaxNum, EpisodeExclude, \
-                   Media, EpisodePermanent, MediaPermanentInline
+                   Media, EpisodePermanent, MediaPermanentInline, Category
 
 class GenericAdminViewTest(TestCase):
     fixtures = ['users.xml']
         self.client.logout()
 
     def testAdd(self):
+        category_id = Category.objects.create(name='male').pk
         post_data = {
             "name": u"John Doe",
             # inline data
             "generic_inline_admin-phonenumber-content_type-object_id-MAX_NUM_FORMS": u"0",
             "generic_inline_admin-phonenumber-content_type-object_id-0-id": "",
             "generic_inline_admin-phonenumber-content_type-object_id-0-phone_number": "555-555-5555",
+            "generic_inline_admin-phonenumber-content_type-object_id-0-category": "%s" % category_id,
         }
         response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/contact/add/')
+        self.failUnlessEqual(response.status_code, 200)
         response = self.client.post('/generic_inline_admin/admin/generic_inline_admin/contact/add/', post_data)
         self.failUnlessEqual(response.status_code, 302) # redirect somewhere