views:

153

answers:

2

I want to replace standart {% if %} template tag by "smart if" custom tag from this snippet, because I don't want to write {% load smart_if %} every time. And also "smart if" will come into core template system very soon

I forgot where I saw piece of code, that do this. Does anyone know, how to replace built-in templatetag?

+1  A: 

Not a full solution to replace the "if" tag, but you can automatically load template tags.

John Paulett
Thanks! It's a best solution for me
ramusus
+3  A: 

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.

Gabriel Ross
Thanks! It's what I'm looking for
ramusus