Django 1.3.7 TemplateDoesNotExist error admin/index.html
django, python, ubuntu
Solution
Newer versions of pip will create a wheel for the package, to speed up installation for the next time you use it. However because of this the templates are being installed into the virtual environment root directory.
A workaround to disable wheel creation was added to 1.4.22 - https://github.com/django/django/commit/3b324970e390a6dc4c373db036d6f27300d7fded, however anything before that would've created wheel files which cause problems such as missing templates.
Official support for wheel files was added to 1.5.1 - https://github.com/django/django/commit/4391718f26466f82f943e37368181d5c0520fa35.
With pip version 19, you can skip wheel installation/creation with `pip install --no-binary Django Django==1.3.7`. Older versions of pip may have slightly different command line arguments.
Problem
There are numerous questions asked on this site similar to this one, but I couldn't find one that could explain this particular behavior. I am relatively new to django and ubuntu, so maybe the explanation is simple. This is an old (v1.3.7) django project I'm attempting to migrate to a new server. Here is the full error I am getting in my apache log: ``` TemplateDoesNotExist at /admin/ admin/login.html Request Method: GET Request URL: http://131.212.123.7:26080/glrimon/admin/ Django Version: 1.3.7 Exception Type: TemplateDoesNotExist Exception Value: admin/login.html Exception Location: /.../leave_beave/lib/python2.7/site-packages/django/template/loader.py in find_template, line 138 Python Executable: /.../leave_beave/bin/python ``` `leave_beave` is the name of my virtualenv. Here is the info passed along by the traceback: ``` Template-loader postmortem Django tried loading these templates, in this order: Using loader django.template.loaders.filesystem.Loader: /glri_mon/siteweb/templates/admin/login.html (File does not exist) Using loader django.template.loaders.app_directories.Loader: /glri_mon/siteweb/gps_upload/templates/admin/login.html (File does not exist) /glri_mon/siteweb/siteapp/templates/admin/login.html (File does not exist) /glri_mon/siteweb/glrimon_models/templates/admin/login.html (File does not exist) /glri_mon/siteweb/sdde/templates/admin/login.html (File does not exist) /glri_mon/siteweb/dv/templates/admin/login.html (File does not exist) /glri_mon/siteweb/contains/templates/admin/login.html (File does not exist) /glri_mon/siteweb/sqlwrite/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/cms/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/tinymce/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/mptt/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/menus/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/cms/plugins/text/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/cms/plugins/picture/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/cms/plugins/link/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/cms/plugins/file/templates/admin/login.html (File does not exist) /.../leave_beave/lib/python2.7/site-packages/cms/plugins/snippet/templates/admin/login.html (File does not exist) /glri_mon/siteweb/cmsplugin_rst/templates/admin/login.html (File does not exist) ``` `glri_mon` is the django project directory. Here's the path to the template in question: `/.../leave_beave/django/contrib/admin/templates/admin/index.html`. Any thoughts on why django didn't include that path in it's search? Here are my template loaders from settings.py: ``` TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) ``` I received this same error for an earlier problem, and I solved it by creating a symlink from the templates directory in question (`.../python2.7/site-packages/lib.../package/templates`) to my `/project_dir/templates` directory, which is the one configured as my template directory in settings.py: ``` TEMPLATE_DIRS = ( os.path.join(PATH, 'templates'), ) ``` I did this at the time, since I thought it was a one-off hack solution sort of thing, but now I'm getting the same error for attempting to access the admin page of my site (http://.../admin/). This tells me I'm going about this wrong. I suppose I could add a symlink to every template directory that generates this error, but that doesn't seem like a good idea for a production site. What am I missing here?