mirror of
https://github.com/django/django.git
synced 2025-07-04 01:39:20 +00:00
unicode: Fixed a problem when models had non-ASCII bytestrings for their
verbose_name. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5372 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
087bf45d93
commit
1e8d1c808b
@ -6,6 +6,7 @@ from django.db.models.loading import get_models
|
|||||||
from django.db.models.query import orderlist2sql
|
from django.db.models.query import orderlist2sql
|
||||||
from django.db.models import Manager
|
from django.db.models import Manager
|
||||||
from django.utils.translation import activate, deactivate_all, get_language, string_concat
|
from django.utils.translation import activate, deactivate_all, get_language, string_concat
|
||||||
|
from django.utils.encoding import force_unicode, smart_str
|
||||||
from bisect import bisect
|
from bisect import bisect
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ class Options(object):
|
|||||||
return '<Options for %s>' % self.object_name
|
return '<Options for %s>' % self.object_name
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s.%s" % (self.app_label, self.module_name)
|
return "%s.%s" % (smart_str(self.app_label), smart_str(self.module_name))
|
||||||
|
|
||||||
def verbose_name_raw(self):
|
def verbose_name_raw(self):
|
||||||
"""
|
"""
|
||||||
@ -102,7 +103,7 @@ class Options(object):
|
|||||||
"""
|
"""
|
||||||
lang = get_language()
|
lang = get_language()
|
||||||
deactivate_all()
|
deactivate_all()
|
||||||
raw = unicode(self.verbose_name)
|
raw = force_unicode(self.verbose_name)
|
||||||
activate(lang)
|
activate(lang)
|
||||||
return raw
|
return raw
|
||||||
verbose_name_raw = property(verbose_name_raw)
|
verbose_name_raw = property(verbose_name_raw)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
"""
|
"""
|
||||||
1. Bare-bones model
|
1. Bare-bones model
|
||||||
|
|
||||||
|
0
tests/regressiontests/model_regress/__init__.py
Normal file
0
tests/regressiontests/model_regress/__init__.py
Normal file
16
tests/regressiontests/model_regress/models.py
Normal file
16
tests/regressiontests/model_regress/models.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
class Article(models.Model):
|
||||||
|
headline = models.CharField(maxlength=100, default='Default headline')
|
||||||
|
pub_date = models.DateTimeField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ('pub_date','headline')
|
||||||
|
# A utf-8 verbose name (Ångström's Articles) to test they are valid.
|
||||||
|
verbose_name = "\xc3\x85ngstr\xc3\xb6m's Articles"
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.headline
|
||||||
|
|
||||||
|
__test__ = {'API_TESTS': "" }
|
Loading…
x
Reference in New Issue
Block a user