What is the best location to put templates in django project?
From the Django book, chapter 4:
If you can’t think of an obvious place to put your templates, we recommend creating a templates directory within your Django project (i.e., within the mysite directory you created in Chapter 2, if you’ve been following along with our examples).
This is exactly what I do, and has worked great for me.
My directory structure looks something like this:
/media
for all my CSS/JS/images etc
/templates
for my templates
/projectname
for the main project code (i.e. the Python code)
This is more a personal choice at the project-level. If you are talking about apps that need to be pluggable, then a templates directory in your app is the place where they go default. But project-wide, it is what works best for you.
You could also consider having your templates in a database, using django-dbtemplates. It is also setup for caching, and the django-reversion application which helps you keep old versions of your templates around.
It works quite well, but I'd prefer a little more flexibility on the import/sync to/from filesystem side.
Placed in <PROJECT>/<APP>/templates/<APP>/template.html
for app-specific templates to help with making the app reusable elsewhere.
For general "global" templates I put them in <PROJECT>/templates/template.html