Ticket #4787: ModelChoiceField_update_choices.diff
File ModelChoiceField_update_choices.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 = queryset144 self._queryset = queryset 145 145 self.empty_label = empty_label 146 146 self.cache_choices = cache_choices 147 147 # Call Field instead of ChoiceField __init__() because we don't need … … 149 149 Field.__init__(self, required, widget, label, initial, help_text) 150 150 self.widget.choices = self.choices 151 151 152 153 def _get_queryset(self): 154 return self._queryset 155 156 def _set_queryset(self,queryset): 157 self._queryset = queryset 158 self.widget.choices = self.choices 159 160 queryset = property(_get_queryset,_set_queryset) 161 152 162 def _get_choices(self): 153 163 # If self._choices is set, then somebody must have manually set 154 164 # the property self.choices. In this case, just return self._choices.