python - Django TemplateTags not compiling -
i trying create custom django templatetags project. followed guides available , created tags. tags not being picked up. aren't being compiled (as .pyc
file isn't generated).
the structure my_dir>app>templatetags>markup_tags.py
. folders app
, templatetags
have required __init__.py
file.
my markup_tags.py file is
from django import template random import randint register = template.library() @register.assignment_tag() def random_number(length=3): """ create random integer given length. length of 3 between 100 , 999. length of 4 between 1000 , 9999. """ return randint(10**(length-1), (10**(length)-1))
when check tag using python manage.py shell
command:
from my_dir.app.templatetags import markup_tags
i error:
traceback (most recent call last): file "<console>", line 1, in <module> importerror: no module named templatetags
whats wrong here? thanks.
edit: folder structure
so don't know went wrong templatetags
folder copying app directory wasn't being picked python. deleted , using ide (pycharm
), created new python package
in app, automatically generates new __init__.py
file.
i restarted server , seems work now. weird though!
Comments
Post a Comment