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

not understanding

In this final code challenge, you'll create a tag that will return the proper conjugation of the verb "to be" depending on whether the subject is plural or singular. Example: "There is 1 elf" versus "There are 5 elves".

Start by creating a conjugate_is function for your template tag. It should take a number as an argument. If (and only if) that number equals 1, the function should return the string 'is'.

code_challenges/templatetags/fairy_extras.py
from django import template

register = template.Library()

def conjugate_is(1):
    return template(is)
code_challenges/templates/code_challenges/list.html
{% load fairy_extras %}

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

3 Answers

Todd Anderson
Todd Anderson
4,260 Points

You don't want to pass in the number 1 to your parameter. Pass in a parameter like int, then if the int = 1 return 'is'.

def conjugate_is(int): if int == 1: return 'is'

i tried the following code and it wasn't working.

from django import template

register = template.Library()

def conjugate_is(int): if int = 1: return ('is')

@marcolamoon have you tired double == like what Todd Anderson did cause it worked for me and don't forget to hit enter before if and return o yea no () on is it's just 'is'

This is what is needed to pass the challenge:

def conjugate_is(int): 
    if int == 1: 
        return 'is'