Hi,
I have created a custom template tags library which I would like to use across my application.
I referred this code snippet, http://djangosnippets.org/snippets/342/
but still when I refer the tag in my code as: {% load repeat %}.
It says 'repeat' is not a valid tag library, tried django.templatetags.repeat,django.contrib.staticfiles.templatetags.repeat
Any help would be appreciated.
- Thanks
Ashish
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/4AqRRolTYK0J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
GlxGuru
import os
import sys
# http://djangosnippets.org/snippets/342/
def load_templatetags():
from django.conf import settings
from django.template import add_to_builtins
try:
for lib in settings.TEMPLATE_TAGS:
print 'loading template tag %s'% lib
add_to_builtins(lib)
print django.template.builtins[3].tags
t = django.template.Template('{% load repeat %}')
print t
except AttributeError:
pass
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
load_templatetags()
'templatemyweb.tags.repeat',
)
with which I am using this code snippet, http://djangosnippets.org/snippets/342/
- Regards