Ticket #7488: baseinlineformset.patch

File baseinlineformset.patch, 748 bytes (added by mkibbel@…, 7 years ago)

Patch to BaseInlineFormset.get_query_set

  • newforms/models.py

     
    410410        Returns this FormSet's queryset, but restricted to children of
    411411        self.instance
    412412        """
    413         kwargs = {self.fk.name: self.instance}
    414         return self.model._default_manager.filter(**kwargs)
     413        if self.instance.pk:
     414            kwargs = {self.fk.name: self.instance}
     415            return self.model._default_manager.filter(**kwargs)
     416        else:
     417            return self.model._default_manager.get_empty_query_set()
    415418
    416419    def save_new(self, form, commit=True):
    417420        kwargs = {self.fk.get_attname(): self.instance.pk}
Back to Top