Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#385 closed defect (fixed)

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

Reported by: eugene@… Owned by: adrian
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: UI/UX:

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 Changed 10 years ago by eugene@…

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

comment:2 Changed 10 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [582].

comment:3 Changed 9 years ago by SmileyChris

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