Django templatetags, ImportError

· Tech · No AI

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.

uptime
8,215 days · since 2004
posts
294 · busiest 2026 (64)
words
~143,065 · ~10 h read
topics
tech 239 · personal 55
langs
en 229 · pl 65
written
211 by hand · 83 AI-assisted
projects
3
build
ca50768 · 2026-06-30