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
163,416 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