Ticket #5247: patch6702.diff

File patch6702.diff, 2.8 KB (added by Peter Baumgartner, 15 years ago)

patch against #6702 that passes tests

  • django/contrib/admin/views/main.py

     
    586586
    587587    def get_filters(self, request):
    588588        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:
    590590            filter_fields = [self.lookup_opts.get_field(field_name) \
    591591                              for field_name in self.lookup_opts.admin.list_filter]
    592592            for f in filter_fields:
  • django/newforms/models.py

     
    1010from util import ValidationError
    1111from forms import BaseForm
    1212from fields import Field, ChoiceField, EMPTY_VALUES
    13 from widgets import Select, SelectMultiple, MultipleHiddenInput
     13from widgets import Select, SelectMultiple, MultipleHiddenInput, ModelSelectMultiple
    1414
    1515__all__ = (
    1616    'save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields',
  • django/newforms/widgets.py

     
    1313from django.utils.datastructures import MultiValueDict
    1414from django.utils.html import escape
    1515from django.utils.translation import ugettext
    16 from django.utils.encoding import StrAndUnicode, force_unicode
     16from django.utils.encoding import StrAndUnicode, force_unicode, smart_unicode
    1717from django.utils.safestring import mark_safe
    1818from util import flatatt
    1919
     
    250250        if value is None: value = []
    251251        final_attrs = self.build_attrs(attrs, name=name)
    252252        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.
    254254        for option_value, option_label in chain(self.choices, choices):
    255255            option_value = force_unicode(option_value)
    256256            selected_html = (option_value in str_values) and ' selected="selected"' or ''
     
    262262        if isinstance(data, MultiValueDict):
    263263            return data.getlist(name)
    264264        return data.get(name, None)
     265       
     266    def value_to_str(cls, value):
     267        return smart_unicode(value)
    265268
     269def ModelSelectMultiple(SelectMultiple):
     270    def value_to_str(cls, value):
     271        return super(ModelSelectMultiple, cls).value_to_str(value._get_pk_val())
     272
    266273class RadioInput(StrAndUnicode):
    267274    """
    268275    An object used by RadioFieldRenderer that represents a single
Back to Top