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!

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 Conjugation Tag

2,470 Points

Template Tag Not Working

Please find the code below I am getting an error

from django import template

register = template.Library()

def conjugate_is(elf_count):
    '''Return conjugated verb 'to be' on singular or plural elf counts'''
    if elf_count==1:
        return "is"
        if elf_count!=1:
            return "are"
{% load fairy_extras %}

There {{ num_elf|conjugate_is }} {{ num_elf }} el{{ num_elf|pluralize:"f,ves" }}.

1 Answer

I realize that this is an older post but the reason your template tag isn't working is because you need to remove the

{{ num_elf | conjugate_is }}.

That is for filtering. When wanting to use a simple tag and pass data into it you need to use the form

{% my_tag_function variable_to_pass_in %}