Ticket #8346: simple_replacement_of_widgets.diff

File simple_replacement_of_widgets.diff, 1.7 KB (added by oyvind, 16 years ago)

should fix this issue

  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index 193dabe..fc2db6c 100644
    a b class ModelChoiceField(ChoiceField):  
    457457    """A ChoiceField whose choices are a model QuerySet."""
    458458    # This class is a subclass of ChoiceField for purity, but it doesn't
    459459    # actually use any of ChoiceField's implementation.
     460    widget = Select
    460461    default_error_messages = {
    461462        'invalid_choice': _(u'Select a valid choice. That choice is not one of'
    462463                            u' the available choices.'),
    463464    }
    464465
    465466    def __init__(self, queryset, empty_label=u"---------", cache_choices=False,
    466                  required=True, widget=Select, label=None, initial=None,
     467                 required=True, widget=None, label=None, initial=None,
    467468                 help_text=None, *args, **kwargs):
    468469        self.empty_label = empty_label
    469470        self.cache_choices = cache_choices
    class ModelChoiceField(ChoiceField):  
    523524
    524525class ModelMultipleChoiceField(ModelChoiceField):
    525526    """A MultipleChoiceField whose choices are a model QuerySet."""
     527    widget=SelectMultiple
    526528    hidden_widget = MultipleHiddenInput
    527529    default_error_messages = {
    528530        'list': _(u'Enter a list of values.'),
    class ModelMultipleChoiceField(ModelChoiceField):  
    531533    }
    532534
    533535    def __init__(self, queryset, cache_choices=False, required=True,
    534                  widget=SelectMultiple, label=None, initial=None,
     536                 widget=None, label=None, initial=None,
    535537                 help_text=None, *args, **kwargs):
    536538        super(ModelMultipleChoiceField, self).__init__(queryset, None,
    537539            cache_choices, required, widget, label, initial, help_text,
Back to Top