Jarrod Jarrod - 7 months ago 180
Python Question

Admin Site: TemplateDoesNotExist at /admin/

I'm following Django's official Tutorial 2 but for some reason cannot create an admin site despite following all the steps correctly to my understanding.

This is the error I get:

TemplateDoesNotExist at /admin/
Request Method: GET
Request URL:
Django Version: 1.3.1
Exception Type: TemplateDoesNotExist
Exception Value:
Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loader.py in find_template, line 138
Python Executable: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.2
Python Path:
Server time: Tue, 24 Jan 2012 18:40:03 -0600

The error occurs after I uncomment the following lines (commented):

### urls.py ###
from django.conf.urls.defaults import patterns, include, url

from django.contrib import admin # THIS LINE
admin.autodiscover() # THIS LINE

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)), # THIS LINE

If I comment them again it gets rid of the error.

I do have
in my INSTALLED_APPS in settings.py


Since it works on other people's machines, and since you have the app directories loader enabled, admin site enabled in INSTALLED_APPS, and that's all it should take for templates to be discovered (I mean, what more can one do?) - I can only assume something is wrong with your django installation.

This would be a good chance to start using virtualenvs and a fresh install of django to rule out your settings:

Fire up a terminal, navigate to your project directory (doesn't actually matter...)

pip install virtualenv # if you don't have it.

virtualenv --no-site-packages env 
# this creates a virtual python environment that doesn't include system packages

source env/bin/activate
# this forces your bash session to use that environment

pip install django
# installs a fresh copy of django to your new environment

cd path_to_my_django_project    
# now go to your site directory

python manager.py runserver
# visit admin site.