Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Customizing Django Templates Building Custom Filters Pluralize

Simon Amz
Simon Amz
4,606 Points

Conditional in template with filters

Hi, in this exercise, we need to add conditional to the template, with filter. In my browser, everything goes well but an error occurs each time I run the program on treehouse.

Would you have an idea where I can find the error, I think the question is not very explicit.

code_challenges/templates/code_challenges/list.html
{% if num_elf > 5 %}  
  Wow, that's a lot of elves!
{% else%}
  {{ num_elf }} el{{ num_elf|pluralize:"f,ves" }}
{% endif %}

1 Answer

Hi simon, the first task is just to print {{ elf_num }}. This needs to be present serperate from the if else statement. otherwise your code is pefect and passes just fine :)

{{ num_elf }}
{% if num_elf > 5 %}  
  Wow, that's a lot of elves!
{% else %}
   el{{ num_elf|pluralize:"f,ves" }}
{% endif %}