Opened 14 years ago

Closed 14 years ago

#9413 closed (duplicate)

naming a template tag library the same as an app causes import problems

Reported by: Antti Kaihola Owned by: nobody
Component: Documentation Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The Django documentation warns about name clashes between custom tag libraries. However, there's no mention about the following problem:

If you have the same name for an app and a tag library, you can't import the app from any other tag libraries. Python first looks up the name among all tag libraries, finds the module there and tries to import that.

This behavior and the incompleteness of the documentation was confirmed by Eric Holscher and lericson on #django-dev a few minutes ago.

Change History (2)

comment:1 Changed 14 years ago by Antti Kaihola

I had this problem with the photologue re-usable app and had to get this working. So here's a dirty work-around.

Say you have the following file structure under a directory which is in PYTHONPATH:


In, this is going to fail:

from photologue.models import Photo

Instead, you can

photologue_models = __import__('photologue.models', {}, {}, [''])
Photo = photologue_models.Photo

comment:2 Changed 14 years ago by Malcolm Tredinnick

Resolution: duplicate
Status: newclosed

This is a symptom of #6587.

Note: See TracTickets for help on using tickets.
Back to Top