Ticket #6045: related.py.diff

File related.py.diff, 1.1 KB (added by Dmitry Gorbunow, 13 years ago)

The better version

  • db/models/fields/related.py

     
    55from django.utils.text import capfirst
    66from django.utils.translation import ugettext_lazy, string_concat, ungettext, ugettext as _
    77from django.utils.functional import curry
    8 from django.utils.encoding import smart_unicode
     8from django.utils.encoding import smart_unicode, smart_str
    99from django.core import validators
    1010from django import oldforms
    1111from django import newforms as forms
     
    281281                raise ValueError("%r instance needs to have a primary key value before a many-to-many relationship can be used." % model)
    282282
    283283        def get_query_set(self):
     284            for key, value in self.core_filters.items():
     285                if not isinstance(key, str):
     286                    del self.core_filters[key]
     287                    self.core_filters[smart_str(key)] = smart_str(value)
    284288            return superclass.get_query_set(self).filter(**(self.core_filters))
    285289
    286290        def add(self, *objs):
Back to Top