Author: mtredinnick
Date: 2007-05-28 06:04:13 -0500 (Mon, 28 May 2007)
New Revision: 5372

Added:
   django/branches/unicode/tests/regressiontests/model_regress/
   django/branches/unicode/tests/regressiontests/model_regress/__init__.py
   django/branches/unicode/tests/regressiontests/model_regress/models.py
Modified:
   django/branches/unicode/django/db/models/options.py
   django/branches/unicode/tests/modeltests/basic/models.py
Log:
unicode: Fixed a problem when models had non-ASCII bytestrings for their
verbose_name.


Modified: django/branches/unicode/django/db/models/options.py
===================================================================
--- django/branches/unicode/django/db/models/options.py 2007-05-28 05:41:32 UTC 
(rev 5371)
+++ django/branches/unicode/django/db/models/options.py 2007-05-28 11:04:13 UTC 
(rev 5372)
@@ -6,6 +6,7 @@
 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 @@
 
     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 @@
         """
         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)

Modified: django/branches/unicode/tests/modeltests/basic/models.py
===================================================================
--- django/branches/unicode/tests/modeltests/basic/models.py    2007-05-28 
05:41:32 UTC (rev 5371)
+++ django/branches/unicode/tests/modeltests/basic/models.py    2007-05-28 
11:04:13 UTC (rev 5372)
@@ -1,3 +1,4 @@
+# coding: utf-8
 """
 1. Bare-bones model
 

Added: django/branches/unicode/tests/regressiontests/model_regress/__init__.py
===================================================================

Added: django/branches/unicode/tests/regressiontests/model_regress/models.py
===================================================================
--- django/branches/unicode/tests/regressiontests/model_regress/models.py       
                        (rev 0)
+++ django/branches/unicode/tests/regressiontests/model_regress/models.py       
2007-05-28 11:04:13 UTC (rev 5372)
@@ -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': "" }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to