Ticket #5247: patch6702.diff
File patch6702.diff, 2.8 KB (added by , 17 years ago) |
---|
-
django/contrib/admin/views/main.py
586 586 587 587 def get_filters(self, request): 588 588 filter_specs = [] 589 if self.lookup_opts.admin.list_filter and not self.opts.one_to_one_field:589 if self.lookup_opts.admin.list_filter: # and not self.opts.one_to_one_field: 590 590 filter_fields = [self.lookup_opts.get_field(field_name) \ 591 591 for field_name in self.lookup_opts.admin.list_filter] 592 592 for f in filter_fields: -
django/newforms/models.py
10 10 from util import ValidationError 11 11 from forms import BaseForm 12 12 from fields import Field, ChoiceField, EMPTY_VALUES 13 from widgets import Select, SelectMultiple, MultipleHiddenInput 13 from widgets import Select, SelectMultiple, MultipleHiddenInput, ModelSelectMultiple 14 14 15 15 __all__ = ( 16 16 'save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields', -
django/newforms/widgets.py
13 13 from django.utils.datastructures import MultiValueDict 14 14 from django.utils.html import escape 15 15 from django.utils.translation import ugettext 16 from django.utils.encoding import StrAndUnicode, force_unicode 16 from django.utils.encoding import StrAndUnicode, force_unicode, smart_unicode 17 17 from django.utils.safestring import mark_safe 18 18 from util import flatatt 19 19 … … 250 250 if value is None: value = [] 251 251 final_attrs = self.build_attrs(attrs, name=name) 252 252 output = [u'<select multiple="multiple"%s>' % flatatt(final_attrs)] 253 str_values = set([ force_unicode(v) for v in value]) # Normalize to strings.253 str_values = set([self.value_to_str(v) for v in value]) # Normalize to strings. 254 254 for option_value, option_label in chain(self.choices, choices): 255 255 option_value = force_unicode(option_value) 256 256 selected_html = (option_value in str_values) and ' selected="selected"' or '' … … 262 262 if isinstance(data, MultiValueDict): 263 263 return data.getlist(name) 264 264 return data.get(name, None) 265 266 def value_to_str(cls, value): 267 return smart_unicode(value) 265 268 269 def ModelSelectMultiple(SelectMultiple): 270 def value_to_str(cls, value): 271 return super(ModelSelectMultiple, cls).value_to_str(value._get_pk_val()) 272 266 273 class RadioInput(StrAndUnicode): 267 274 """ 268 275 An object used by RadioFieldRenderer that represents a single