Ticket #10015: 10015_r9729.diff

File 10015_r9729.diff, 902 bytes (added by Carl Meyer, 16 years ago)

fix by introspection of ct_fk_field in BaseGenericInlineFormset

  • django/contrib/contenttypes/generic.py

     
    310310            return self.model._default_manager.empty()
    311311        return self.model._default_manager.filter(**{
    312312            self.ct_field.name: ContentType.objects.get_for_model(self.instance),
    313             self.ct_fk_field.name: self.instance.pk,
     313            self.ct_fk_field.name: self._cast_instance_pk(self.instance.pk),
    314314        })
    315315
     316    def _cast_instance_pk(self, pk):
     317        if self.ct_fk_field.get_internal_type() == 'TextField':
     318            return smart_unicode(pk)
     319        return pk
     320
    316321    def save_new(self, form, commit=True):
    317322        # Avoid a circular import.
    318323        from django.contrib.contenttypes.models import ContentType
Back to Top