#12434: django.contrib.admin does not work with blank short_description
-------------------------------------------+--------------------------------
          Reporter:  anonymous             |         Owner:  gabrielhurley
            Status:  assigned              |     Milestone:  1.2          
         Component:  django.contrib.admin  |       Version:  SVN          
        Resolution:                        |      Keywords:               
             Stage:  Accepted              |     Has_patch:  1            
        Needs_docs:  0                     |   Needs_tests:  0            
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by gabrielhurley):

  * owner:  nobody => gabrielhurley
  * status:  new => assigned
  * has_patch:  0 => 1

Comment:

 Capitalize works fine for international characters as long as the string
 is a unicode string:

 {{{
 >>> print u'ñ'.capitalize()
 Ñ
 }}}

 Even though it's probably overkill for a small patch, I ran some timeit
 tests to see how various solutions to this problem compared:

 {{{
 >>> import timeit
 >>> t1 = """\
 ... name = u'el_ñino_season'
 ... name.capitalize().replace('_', ' ')
 ... """
 >>> timeit.timeit(t1)
 2.1008538794735085
 >>> t2 = """\
 ... name = u'el_ñino_season'
 ... name.upper().replace('_', ' ')
 ... """
 >>> timeit.timeit(t2)
 2.2086846233250319
 >>> t3 = """\
 ... name = u'el_ñino_season'
 ... name = name.upper()
 ... name.replace('_', ' ')
 ... """
 >>> timeit.timeit(t3)
 2.1825877311222515
 >>> t4 = """\
 ... name = u'el_ñino_season'
 ... if not name:
 ...     return u''
 ... name.replace('_', ' ').capitalize()
 ... """
 >>> timeit.timeit(t4)
 2.1088863905887484
 }}}

 My patch reflects option 4, which is consistently fast and handles the
 case of name being None.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12434#comment:7>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to