Ticket #4292: 4292.diff

File 4292.diff, 2.5 KB (added by Ivan Sagalaev <Maniac@…>, 8 years ago)

Patch

  • django/contrib/contenttypes/models.py

     
    11from django.db import models
    22from django.utils.translation import ugettext_lazy as _
     3from django.utils.encoding import smart_unicode
    34
    45CONTENT_TYPE_CACHE = {}
    56class ContentTypeManager(models.Manager):
     
    1617            # The str() is needed around opts.verbose_name because it's a
    1718            # django.utils.functional.__proxy__ object.
    1819            ct, created = self.model._default_manager.get_or_create(app_label=key[0],
    19                 model=key[1], defaults={'name': str(opts.verbose_name)})
     20                model=key[1], defaults={'name': smart_unicode(opts.verbose_name)})
    2021            CONTENT_TYPE_CACHE[key] = ct
    2122        return ct
    2223
  • django/utils/functional.py

     
    3232                self.__dispatch[resultclass] = {}
    3333                for (k, v) in resultclass.__dict__.items():
    3434                    setattr(self, k, self.__promise__(resultclass, k, v))
     35            if unicode in resultclasses:
     36                setattr(self, '__unicode__', self.__unicode_cast)
    3537
    3638        def __promise__(self, klass, funcname, func):
    3739            # Builds a wrapper around some magic method and registers that magic
     
    4749            self.__dispatch[klass][funcname] = func
    4850            return __wrapper__
    4951
     52        def __unicode_cast(self):
     53            return self.__func(*self.__args, **self.__kw)
     54
    5055    def __wrapper__(*args, **kw):
    5156        # Creates the proxy object, instead of the actual value.
    5257        return __proxy__(args, kw)
  • django/utils/translation/trans_real.py

     
    510510    """"
    511511    lazy variant of string concatenation, needed for translations that are
    512512    constructed from multiple parts. Handles lazy strings and non-strings by
    513     first turning all arguments to strings, before joining them.
     513    first turning all arguments to unicode, before joining them.
    514514    """
    515     return ''.join([str(el) for el in strings])
    516 
     515    return u''.join([smart_unicode(el) for el in strings])
     516 No newline at end of file
Back to Top