i am newbie to django and learning by doing small application.
in views.py i have intentionally included a template file(.html) which does not exist.
t = get_template('current_datetimeP.html')
in setting.py
TEMPLATE_DIRS = (
“D:/Django_Code/mysite/templates/”,
)
i get this error TemplateDoesNotExist at /time/
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
D:\Django_Code\mysite\templates\current_datetimeP.html (File does not exist)
since i have included D:\Django_Code\mysite\templates\ in settings.py its fine that the Django is loking in there but what about following
I also get this
Using loader django.template.loaders.app_directories.Loader:
C:\Python27\lib\site-packages\django\contrib\auth\templates\current_datetimeP.html (File does not exist)
Why Django looking in here *C:\Python27\lib\site-packages\django\contrib\auth\templates*.
Is it a default location to search templates ?
one more thing , its is evident that Django is looking in above directory. can we place templates file in there instead of putting in application directory. (Although it is not a good practice ) ?
Template loading is controlled by the TEMPLATE_LOADERS setting in settings.py, which usually looks something like this:
The app directories loader looks for templates in a “templates” folder in any of the apps listed in INSTALLED_APPS in settings.
The filesystem loader attempts to load templates from the fully qualified directory path names listed under TEMPLATE_DIRS in the settings file.
If you wish to give the filesystem loader preference, let it come before the app directories loader in the TEMPLATE_LOADERS setting. If you’d like to turn off app directories loading, comment it out with a # ( or delete it from the tuple ).