Ticket #4046: 4046.diff
File 4046.diff, 1.7 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/related.py
549 549 setattr(cls, related.get_accessor_name(), ForeignRelatedObjectsDescriptor(related)) 550 550 551 551 def formfield(self, **kwargs): 552 defaults = {'form_class': forms.ModelChoiceField, 'queryset': self.rel.to._default_manager. all()}552 defaults = {'form_class': forms.ModelChoiceField, 'queryset': self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)} 553 553 defaults.update(kwargs) 554 554 return super(ForeignKey, self).formfield(**defaults) 555 555 … … 625 625 cls._meta.one_to_one_field = self 626 626 627 627 def formfield(self, **kwargs): 628 defaults = {'form_class': forms.ModelChoiceField, 'queryset': self.rel.to._default_manager. all()}628 defaults = {'form_class': forms.ModelChoiceField, 'queryset': self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)} 629 629 defaults.update(kwargs) 630 630 return super(OneToOneField, self).formfield(**defaults) 631 631 … … 757 757 setattr(instance, self.attname, data) 758 758 759 759 def formfield(self, **kwargs): 760 defaults = {'form_class': forms.ModelMultipleChoiceField, 'queryset': self.rel.to._default_manager. all()}760 defaults = {'form_class': forms.ModelMultipleChoiceField, 'queryset': self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)} 761 761 defaults.update(kwargs) 762 762 # If initial is passed in, it's a list of related objects, but the 763 763 # MultipleChoiceField takes a list of IDs.