I want to replace the standard {% if %}
template tag with a "smart if" custom tag from this snippet, because I don't want to write {% load smart_if %}
every time. Also, "smart if" will come into core template system very soon.
I forgot where I saw a piece of code that does this. Does anyone know how to replace a built-in templatetag?
Place this somewhere you know will get run:
from django.template import add_to_builtins
add_to_builtins('mysite.myapp.templatetags.smart_if')
... while placing smart_if.py containing the smart_if code at the appropriate location. This effectively overrides the if tag with "smart if" accross the whole site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With