Opened 13 years ago

Closed 13 years ago

#294 closed enhancement (fixed)

Use setuptools more aggressively for templates

Reported by: Michael Twomey <micktwomey@…> Owned by: Adrian Holovaty
Component: Template system Version:
Severity: normal Keywords: template setuptools
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Locating templates provides the major source of my problems in setting up new django sites from a source checkout. Since most of my templates are closely associated with the python code in the apps it makes sense for me to use setuptools' resource location abilities to find templates.

For example in myproject/settings/

from pkg_resources import resource_filename

resource_filename('django.conf', 'admin_templates')


It would be really nice if this approach was encouraged as it would remove most of the problems for first time users setting up their sites. In fact, if django tried a set of standard locations for templates using resource_filename it should allow people to setup django sites easily just by checking out python modules and adding them to the INSTALLED_APPS. For example myproject/apps/myapp/templates could be a useful default. PS this issue gets a submitter-just-drank-5-pints-of-guinness rating in terms of coherence, try me tomorrow for more elaboration.

Change History (4)

comment:1 Changed 13 years ago by Adrian Holovaty

milestone: Version 1.0

comment:2 Changed 13 years ago by garthk@…

Just searching through sitename.apps.appname.templates and sitename.templates would be nice. Though, the former might require the kind of introspection I was decrying in {122}. :)

comment:3 Changed 13 years ago by Matthew Good <trac@…>

Yes! I just did this on my config and was going to submit a ticket of my own. Using resource_filename is ok as long as the templates are not in a zipped EGG although it's recommended to use the resource_string to read resources directly from the EGG. So, it may be good for the template loader to have a mechanism for loading templates via pkg_resources. See

comment:4 Changed 13 years ago by rjwittams

Resolution: fixed
Status: newclosed

This seems to be resolved with the new template loading framework : templates can be loaded out of an egg or an app.
Reopen if you feel this still an issue.

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