TemplateDoesNotExist at /admin/ admin/index.html
I am unable to access the admin interface in django 1.1.1 using localloop:8000/admin
. It was working fine on Ubuntu 8.4 then I upgraded to Ubuntu 10.10 and the problem occurred.
In settings.py
I have:
import os.path
PROJECT_DIR=os.path.dirname(__file__)
TEMPLATE_DIRS =(os.path.join(PROJECT_DIR,'templates'))
This was working fine on Ubuntu 8.04 but not in Ubuntu 10.10.
Any ideas on what goes wrong? Here is the traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.1.1
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'hotweb.accounts',
'django.contrib.flatpages',
'messages',
'hotweb.jchat']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.middleware.http.SetRemoteAddrFromForwardedFor')
Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/home/scorpion/Desktop/hotweb/templates/admin/index.html (File does not exist)
Using loader django.template.loaders.app_directories.load_template_source:
/usr/local/lib/python2.6/dist-packages/django/contrib/admin/templates/admin/index.html (File exists)
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in wrapper
196. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in inner
186. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in index
374. context_instance=context_instance
File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in render_to_string
103. t = get_template(template_name)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in get_template
81. source, origin = find_template_source(template_name)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in find_template_source
74. raise TemplateDoesNotExist, name
Exception Type: TemplateDoesNotExist at /admin/
Exception Value: admin/index.html
here is the trace back
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.1.1
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.adm开发者_开发问答in',
'hotweb.accounts',
'django.contrib.flatpages',
'messages',
'hotweb.jchat']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.middleware.http.SetRemoteAddrFromForwardedFor')
Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/home/scorpion/Desktop/hotweb/templates/admin/index.html (File does not exist)
Using loader django.template.loaders.app_directories.load_template_source:
/usr/local/lib/python2.6/dist-packages/django/contrib/admin/templates/admin/index.html (File exists)
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in wrapper
196. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in inner
186. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in index
374. context_instance=context_instance
File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in render_to_string
103. t = get_template(template_name)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in get_template
81. source, origin = find_template_source(template_name)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in find_template_source
74. raise TemplateDoesNotExist, name
Exception Type: TemplateDoesNotExist at /admin/
Exception Value: admin/index.html
Ensure that APP_DIRS
is set to True
in the Templates
Hmm, that's odd since TEMPLATE_DIRS
setting doesn't have anything to do with the admin app.
If you're sure it's those 3 lines, the only possible thing I see wrong is TEMPLATE_DIRS
is supposed to be a tuple (yours is a string), but on 1.2.3 it doesn't cause any problems.
You say "the problem occurred in settings.py"... but I don't see where a TemplateDoesNotExist error would appear from the lines you pasted -- can you post the full traceback? Which line of code triggered TemplateDoesNotExist? How do you know it was settings.py?
I think the problem lies outside of your 3 lines.
PS: I can't comment since I have <50 rep.
精彩评论