Ticket #5830: modelchoicefield_queryset_as_property.diff
File modelchoicefield_queryset_as_property.diff, 1.2 KB (added by , 17 years ago) |
---|
-
django/newforms/models.py
141 141 # actually use any of ChoiceField's implementation. 142 142 def __init__(self, queryset, empty_label=u"---------", cache_choices=False, 143 143 required=True, widget=Select, label=None, initial=None, help_text=None): 144 self.queryset = queryset145 144 self.empty_label = empty_label 146 145 self.cache_choices = cache_choices 147 146 # Call Field instead of ChoiceField __init__() because we don't need 148 147 # ChoiceField.__init__(). 149 148 Field.__init__(self, required, widget, label, initial, help_text) 149 self.queryset = queryset 150 151 def _get_queryset(self): 152 return self._queryset 153 154 def _set_queryset(self, queryset): 155 self._queryset = queryset 150 156 self.widget.choices = self.choices 151 157 158 queryset = property(_get_queryset, _set_queryset) 159 152 160 def _get_choices(self): 153 161 # If self._choices is set, then somebody must have manually set 154 162 # the property self.choices. In this case, just return self._choices.