Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#385 closed defect (fixed)

[patch] yesno filter is broken: doesn't accept 2-value argument

Reported by: eugene@… Owned by: Adrian Holovaty
Component: Template system Version:
Severity: major Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

yesno filter throws exception, when it is used with 2-value argument:

{{ mylist|length_is:"1"|yesno:"datum,data" }}

This path works for me:

--- C:\Documents and Settings\Eugene\Local Settings\Temp\defaultfilters-HEAD.py	Sun Aug 21 08:34:15 2005
+++ c:\Projects\Django\django\core\defaultfilters.py	Sun Aug 21 08:27:28 2005
@@ -367,7 +367,7 @@
     try:
         yes, no, maybe = bits
     except ValueError: # unpack list of wrong size (no "maybe" value provided)
-        yes, no, maybe = bits, bits[1]
+        yes, no, maybe = bits[0], bits[1], bits[1]
     if value is None:
         return maybe
     if value:

PS: Is there any simple way to pluralize non-regular nouns? Something like this would be nice to have:

{{ mylist|pluralize:"datum,data" }}

Change History (3)

comment:1 by eugene@…, 19 years ago

Summary: [patch] '''yesno''' filter is broken: doesn't accept 2-value argument[patch] yesno filter is broken: doesn't accept 2-value argument

comment:2 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

Fixed in [582].

comment:3 by Chris Beaven, 18 years ago

In regards to the PS about pluralizing non-regular nouns, that has been fixed in [3272].

Note: See TracTickets for help on using tickets.
Back to Top