Ticket #7244: 0001-Fixed-widget-handling-in-ModelChoicesField.__init__.2.patch

File 0001-Fixed-widget-handling-in-ModelChoicesField.__init__.2.patch, 2.2 KB (added by sebastian_noack, 7 years ago)
  • django/newforms/models.py

    From 7003efb48b699a0f1addca8b94080a1763f08195 Mon Sep 17 00:00:00 2001
    From: Sebastian Noack <sebastian.noack@gmail.com>
    Date: Thu, 15 May 2008 16:18:23 +0200
    Subject: [PATCH] Fixed widget handling in ModelChoicesField.__init__ and ModelMultipleChoicesField.__init__ (#7244).
    
    ---
     django/newforms/models.py |    9 +++++----
     1 files changed, 5 insertions(+), 4 deletions(-)
    
    diff --git a/django/newforms/models.py b/django/newforms/models.py
    index 78a2041..9b74076 100644
    a b from django.core.exceptions import ImproperlyConfigured 
    1313from util import ValidationError, ErrorList
    1414from forms import BaseForm, get_declared_fields
    1515from fields import Field, ChoiceField, EMPTY_VALUES
    16 from widgets import Select, SelectMultiple, MultipleHiddenInput
     16from widgets import SelectMultiple, MultipleHiddenInput
    1717
    1818__all__ = (
    1919    'ModelForm', 'BaseModelForm', 'model_to_dict', 'fields_for_model',
    class ModelChoiceField(ChoiceField): 
    301301    }
    302302
    303303    def __init__(self, queryset, empty_label=u"---------", cache_choices=False,
    304                  required=True, widget=Select, label=None, initial=None,
     304                 required=True, widget=None, label=None, initial=None,
    305305                 help_text=None, *args, **kwargs):
    306306        self.empty_label = empty_label
    307307        self.cache_choices = cache_choices
    class ModelChoiceField(ChoiceField): 
    360360
    361361class ModelMultipleChoiceField(ModelChoiceField):
    362362    """A MultipleChoiceField whose choices are a model QuerySet."""
     363    widget = SelectMultiple
    363364    hidden_widget = MultipleHiddenInput
    364365    default_error_messages = {
    365366        'list': _(u'Enter a list of values.'),
    class ModelMultipleChoiceField(ModelChoiceField): 
    368369    }
    369370
    370371    def __init__(self, queryset, cache_choices=False, required=True,
    371                  widget=SelectMultiple, label=None, initial=None,
    372                  help_text=None, *args, **kwargs):
     372                 widget=None, label=None, initial=None, help_text=None,
     373                 *args, **kwargs):
    373374        super(ModelMultipleChoiceField, self).__init__(queryset, None,
    374375            cache_choices, required, widget, label, initial, help_text,
    375376            *args, **kwargs)
Back to Top