Django

Code

Ticket #4787: ModelChoiceField_widget_choices.patch

File ModelChoiceField_widget_choices.patch, 0.7 kB (added by fero <luca.ferroni@labs.it>, 1 year ago)

Proposed patch

  • newforms/models.py

    old new  
    142142        Field.__init__(self, required, widget, label, initial, help_text) 
    143143        self.widget.choices = self.choices 
    144144 
     145    def _get_queryset(self): 
     146        return self._queryset 
     147 
     148    def _set_queryset(self, value): 
     149        self._queryset = value 
     150        self.widget.choices = self.choices 
     151 
     152    queryset = property(_get_queryset, _set_queryset) 
     153 
    145154    def _get_choices(self): 
    146155        # If self._choices is set, then somebody must have manually set 
    147156        # the property self.choices. In this case, just return self._choices.