Question

"TemplateDoesNotExist at /". Why not? Or why the error?

Posted September 15, 2015 19.8k views
UbuntuPythonDjango

Installed Django 1.8.4, Python 2.7.9 and SwampDragon 0.4.2.2; executed “ ./manage.py runserver 0.0.0.0:8000” and selected http://<mysite>:8000 in Opera browser. Django debug enabled.


Request Method: GET
Request URL:    http://<mysite>:8000/
Django Version: 1.8.4
Exception Type: TemplateDoesNotExist
Exception Value:    
index.html
Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/loader.py in select_template, line 76
Python Executable:  /usr/bin/python
Python Version: 2.7.9
Python Path:    
['/home/admin/www/swampdragon.net',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages']

Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/index.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/index.html (File does not exist)

Which is correct - those files do not exist! There are several files in /usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/admin however, including index.html:

total 112
-rw-r--r-- 1 root staff 1140 Sep 15 21:00 search_form.html
-rw-r--r-- 1 root staff  790 Sep 15 21:00 submit_line.html
-rw-r--r-- 1 root staff 1469 Sep 15 21:00 related_widget_wrapper.html
-rw-r--r-- 1 root staff 1012 Sep 15 21:00 prepopulated_fields_js.html
-rw-r--r-- 1 root staff  491 Sep 15 21:00 popup_response.html
-rw-r--r-- 1 root staff  561 Sep 15 21:00 pagination.html
-rw-r--r-- 1 root staff 1440 Sep 15 21:00 object_history.html
-rw-r--r-- 1 root staff 1695 Sep 15 21:00 login.html
-rw-r--r-- 1 root staff  437 Sep 15 21:00 invalid_setup.html
-rw-r--r-- 1 root staff 2989 Sep 15 21:00 index.html
-rw-r--r-- 1 root staff  301 Sep 15 21:00 filter.html
-rw-r--r-- 1 root staff 2209 Sep 15 21:00 delete_selected_confirmation.html
-rw-r--r-- 1 root staff 2301 Sep 15 21:00 delete_confirmation.html
-rw-r--r-- 1 root staff  372 Sep 15 21:00 date_hierarchy.html
-rw-r--r-- 1 root staff 1559 Sep 15 21:00 change_list_results.html
-rw-r--r-- 1 root staff 3512 Sep 15 21:00 change_list.html
-rw-r--r-- 1 root staff 3697 Sep 15 21:00 change_form.html
-rw-r--r-- 1 root staff  316 Sep 15 21:00 base_site.html
-rw-r--r-- 1 root staff 3667 Sep 15 21:00 base.html
-rw-r--r-- 1 root staff  385 Sep 15 21:00 app_index.html
-rw-r--r-- 1 root staff 1095 Sep 15 21:00 actions.html
-rw-r--r-- 1 root staff  527 Sep 15 21:00 500.html
-rw-r--r-- 1 root staff  268 Sep 15 21:00 404.html
drwxr-sr-x 4 root staff 4096 Sep 15 21:00 ../
drwxr-sr-x 2 root staff 4096 Sep 15 21:00 includes/
drwxr-sr-x 2 root staff 4096 Sep 15 21:00 edit_inline/
drwxr-sr-x 3 root staff 4096 Sep 15 21:00 auth/
drwxr-sr-x 5 root staff 4096 Sep 15 21:00 ./

Given that this is essentially an “out-of-the-box” installation - particularly where the ‘admin’ files are concerned - is this a Django bug?

I have Googled for the “TemplateDoesNotExist at /” error message but although others have encountered similar problems, there does not seem to be a definitive solution. Which is surprising, as this appears to be a fundamental issue.

Perhaps I will simply disable the Django admin facility for the time being.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Oops! This was due to the inclusion of the following line in the urls.py file:

 url(r'^$', TemplateView.as_view(template_name='index.html'), name='home'),

I had derived that from the tutorial at http://swampdragon.net/tutorial/part-2-swampdragon-tutorial.

I’ve no idea why that didn’t work but if I omit the line I get the basic “Welcome to Django” web service running.

Submit an Answer