Do not use appname as templatetags module
This is the second time I created same error writing templatetags, so it is about time to document it.
This is the bad layout for poll app.
polls/
__init__.py
models.py
templatetags/
__init__.py
polls.py
views.py
Instead of polls.py it should be polls_tags.py or something other different from appname.
Whats going on? polls.py would define polls module and it would not be possible to import other modules from original polls application.
For example the code bellow would throw ImportError: No module named models
#polls.py from django import template from polls.models import Question register = template.Library()
I am Bojan Mihelac and this blog is dedicated to share code, thoughts, tools and advices I came up with while working at
blog comments powered by Disqus