Yesterday I wrote templatetag in Django 1.5. Simple code, about 10 lines. Nothing special. I run runserver, refreshed page and i got error.
ImportError raised loading favorites.templatetags.favorites: No module named models
I checked all path, imports, circural/cross imports. I moved imports to methods. I did small code refactoring. And still the same! Finally, after 1 hour i have found an issue. My django application has the same name as file in templatetag directory. (simple, huh?)
So I had something like this:
favorites/templatetags/favorites.py
In favorites.py:
from favorites.models import Favorites
In template:
{% load favorites %}
Changing templatetag’s filename has fixed the problem.
Maybe it will save someone’s time.