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 Reverse Text Filter

My Code Works Perfectly but the Engine does not detect it

from django import template

register = template.Library()

@register.filter('reverse_text') def reverse_text(proper_text): new_text='' for l in test: new_text=l+new_text

return new_text
code_challenges/templatetags/extras.py
from django import template

register = template.Library()

@register.filter('reverse_text')
def reverse_text(proper_text):
    new_text=''
    for l in test:
        new_text=l+new_text

    return new_text

2 Answers

Steven Parker
Steven Parker
229,708 Points

In your external testing, you may have had a global variable named "test" that you were using as the argument to call the function with, or happened to have the same contents as the argument.

But there's nothing named "test" defined in the code here. Perhaps you intended to use "proper_text" as the loop iterable instead?

Yes, silly me