1
0
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:
Malcolm Tredinnick 2007-05-28 11:04:13 +00:00
parent 087bf45d93
commit 1e8d1c808b
4 changed files with 21 additions and 3 deletions

View File

@ -6,6 +6,7 @@ from django.db.models.loading import get_models
from django.db.models.query import orderlist2sql
from django.db.models import Manager
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
import re
@ -90,9 +91,9 @@ class Options(object):
def __repr__(self):
return '<Options for %s>' % self.object_name
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):
"""
@ -102,7 +103,7 @@ class Options(object):
"""
lang = get_language()
deactivate_all()
raw = unicode(self.verbose_name)
raw = force_unicode(self.verbose_name)
activate(lang)
return raw
verbose_name_raw = property(verbose_name_raw)

View File

@ -1,3 +1,4 @@
# coding: utf-8
"""
1. Bare-bones model

View 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': "" }