Ticket #11302: generic-formset-optimization.diff

File generic-formset-optimization.diff, 707 bytes (added by Alex, 6 years ago)
  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    index 5564548..4df48ff 100644
    a b class BaseGenericInlineFormSet(BaseModelFormSet): 
    317317    def get_queryset(self):
    318318        # Avoid a circular import.
    319319        from django.contrib.contenttypes.models import ContentType
    320         if self.instance is None:
     320        if self.instance is None or self.instance.pk is None:
    321321            return self.model._default_manager.none()
    322322        return self.model._default_manager.filter(**{
    323323            self.ct_field.name: ContentType.objects.get_for_model(self.instance),
Back to Top