#10143: "add" template filter always converts arguments to integers
---------------------------------------------+------------------------------
          Reporter:  jfw                     |         Owner:  nobody
            Status:  new                     |     Milestone:        
         Component:  Template system         |       Version:  1.0   
        Resolution:                          |      Keywords:        
             Stage:  Design decision needed  |     Has_patch:  0     
        Needs_docs:  0                       |   Needs_tests:  0     
Needs_better_patch:  0                       |  
---------------------------------------------+------------------------------
Comment (by jfw):

 I see how that would be a pain.  Here's an idea--feel free to shoot it
 down.  What about coercing the second argument to be the same type as the
 first?  Presumably (and I know there would be cases where this presumption
 is wrong,) the first type *should* be the "right" type for the situation--
 it's most likely coming from the context, and therefore probably won't be
 a string (unless that's the intent.)  Something like this:

 {{{
 def add(value, arg):
     try:
         return value + type(value)(arg)
     except ValueError:
         return int(value) + int(arg)
 }}}

 Thoughts?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10143#comment:2>
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-updates@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