One thing I absolutely love about Django’s template loading

Is the ability to specify a series of template folders in [your settings file](http://www.djangoproject.com/documentation/settings/#template-dirs).

Here’s what we do at [work](http://www.ajc.com):

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), "templates"),
    os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "ANOTHERSITE", "templates")),
)

It allows us to easily share templates from ANOTHERSITE with sister/sub sites, but when/if you need to override them you just drop your new template your site’s templates folder and you’re off to the races.

###Another template tip
If you use the tip above, I’d recommend putting templates that are explicity shared in a templates/shared folder.

Then you can do things like:


{% extends 'shared/shared_somethingorother.html' %}

It’s a minor tip, but it helps prevent collisions and alerts developers that these templates shouldn’t have any site specific code in them.

This entry was posted in Django, Python. Bookmark the permalink.