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
|
13 | 13 | from util import ValidationError, ErrorList |
14 | 14 | from forms import BaseForm, get_declared_fields |
15 | 15 | from fields import Field, ChoiceField, EMPTY_VALUES |
16 | | from widgets import Select, SelectMultiple, MultipleHiddenInput |
| 16 | from widgets import SelectMultiple, MultipleHiddenInput |
17 | 17 | |
18 | 18 | __all__ = ( |
19 | 19 | 'ModelForm', 'BaseModelForm', 'model_to_dict', 'fields_for_model', |
… |
… |
class ModelChoiceField(ChoiceField):
|
301 | 301 | } |
302 | 302 | |
303 | 303 | 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, |
305 | 305 | help_text=None, *args, **kwargs): |
306 | 306 | self.empty_label = empty_label |
307 | 307 | self.cache_choices = cache_choices |
… |
… |
class ModelChoiceField(ChoiceField):
|
360 | 360 | |
361 | 361 | class ModelMultipleChoiceField(ModelChoiceField): |
362 | 362 | """A MultipleChoiceField whose choices are a model QuerySet.""" |
| 363 | widget = SelectMultiple |
363 | 364 | hidden_widget = MultipleHiddenInput |
364 | 365 | default_error_messages = { |
365 | 366 | 'list': _(u'Enter a list of values.'), |
… |
… |
class ModelMultipleChoiceField(ModelChoiceField):
|
368 | 369 | } |
369 | 370 | |
370 | 371 | 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): |
373 | 374 | super(ModelMultipleChoiceField, self).__init__(queryset, None, |
374 | 375 | cache_choices, required, widget, label, initial, help_text, |
375 | 376 | *args, **kwargs) |