Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12434: Made pretty_name handle empty string and None as input.…

… Thanks ales_zoulek and gabrielhurley.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12794 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cc6e9b22864a0dd72bcc778ab3f673853ee4987d 1 parent 3c59067
Karen Tracey authored March 16, 2010
7  django/forms/forms.py
@@ -18,9 +18,10 @@
18 18
 NON_FIELD_ERRORS = '__all__'
19 19
 
20 20
 def pretty_name(name):
21  
-    "Converts 'first_name' to 'First name'"
22  
-    name = name[0].upper() + name[1:]
23  
-    return name.replace('_', ' ')
  21
+    """Converts 'first_name' to 'First name'""" 
  22
+    if not name: 
  23
+        return u'' 
  24
+    return name.replace('_', ' ').capitalize() 
24 25
 
25 26
 def get_declared_fields(bases, attrs, with_base_fields=True):
26 27
     """
2  tests/regressiontests/admin_views/models.py
@@ -35,6 +35,7 @@ def __unicode__(self):
35 35
     def model_year(self):
36 36
         return self.date.year
37 37
     model_year.admin_order_field = 'date'
  38
+    model_year.short_description = ''
38 39
 
39 40
 class Book(models.Model):
40 41
     """
@@ -103,6 +104,7 @@ def changelist_view(self, request):
103 104
     def modeladmin_year(self, obj):
104 105
         return obj.date.year
105 106
     modeladmin_year.admin_order_field = 'date'
  107
+    modeladmin_year.short_description = None
106 108
 
107 109
 class CustomArticle(models.Model):
108 110
     content = models.TextField()

0 notes on commit cc6e9b2

Please sign in to comment.
Something went wrong with that request. Please try again.