Ticket #9076: 9076.2.diff

File 9076.2.diff, 1.3 KB (added by Karen Tracey, 16 years ago)
  • django/forms/models.py

     
    463463        self.save_as_new = save_as_new
    464464        # is there a better way to get the object descriptor?
    465465        self.rel_name = RelatedObject(self.fk.rel.to, self.model, self.fk).get_accessor_name()
    466         super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix or self.rel_name)
     466        qs = self.model._default_manager.filter(**{self.fk.name: self.instance})
     467        super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix or self.rel_name,
     468                                                queryset=qs)
    467469
    468470    def _construct_forms(self):
    469471        if self.save_as_new:
     
    479481            form.data[form.add_prefix(self._pk_field.name)] = None
    480482        return form
    481483   
    482     def get_queryset(self):
    483         """
    484         Returns this FormSet's queryset, but restricted to children of
    485         self.instance
    486         """
    487         kwargs = {self.fk.name: self.instance}
    488         return self.model._default_manager.filter(**kwargs)
    489 
    490484    def save_new(self, form, commit=True):
    491485        kwargs = {self.fk.get_attname(): self.instance.pk}
    492486        new_obj = self.model(**kwargs)
Back to Top