Ticket #4046: 4046.qsrf.diff
File 4046.qsrf.diff, 1.3 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/related.py
class ForeignKey(RelatedField, Field): 669 669 setattr(cls, related.get_accessor_name(), ForeignRelatedObjectsDescriptor(related)) 670 670 671 671 def formfield(self, **kwargs): 672 defaults = {'form_class': forms.ModelChoiceField, 'queryset': self.rel.to._default_manager. all()}672 defaults = {'form_class': forms.ModelChoiceField, 'queryset': self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)} 673 673 defaults.update(kwargs) 674 674 return super(ForeignKey, self).formfield(**defaults) 675 675 … … class ManyToManyField(RelatedField, Field): 823 823 setattr(instance, self.attname, data) 824 824 825 825 def formfield(self, **kwargs): 826 defaults = {'form_class': forms.ModelMultipleChoiceField, 'queryset': self.rel.to._default_manager. all()}826 defaults = {'form_class': forms.ModelMultipleChoiceField, 'queryset': self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)} 827 827 defaults.update(kwargs) 828 828 # If initial is passed in, it's a list of related objects, but the 829 829 # MultipleChoiceField takes a list of IDs.