What is the best location to put templates in django project?
What is the best location to put templates in django project?
Solution 1:
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
Solution 2:
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)