python2.73 + django1.6模板 出现这提示。。。。。。

new201456 发布于 2014/06/06 22:06
阅读 2K+
收藏 0
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.6.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'news')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Template Loader Error:
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)



Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/zdj/www/html/sdstu/news/views.py" in index
  77.  return render_to_response('index.html')
File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py" in render_to_response
  29.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
  162.         t = get_template(template_name)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in get_template
  138.     template, origin = find_template(template_name)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in find_template
  131.     raise TemplateDoesNotExist(name)

Exception Type: TemplateDoesNotExist at /
Exception Value: index.html



加载中
0
寒晨
寒晨
TemplateDoesNotExist 
0
n
new201456

settings 里 这样设置:


"""
Django settings for sdstu project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '2p+$=c%@1*914l_ieoodp0p5x5&3!qr$9)-m&blyf3gcq4w6sb'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []

TEMPLATE_DIR = [os.path.join(BASE_DIR, 'templates').replace('\\', '/')]

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'news',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'sdstu.urls'

WSGI_APPLICATION = 'sdstu.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
       # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
	'NAME':'sdstunews',
	'USER':'root',
	'PASSWORD':'12345zxcvb',
	'HOST':'localhost',
	'PROT':'3306',
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'zh-cn'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'



0
n
new201456

在根目录:

project/templates/index.html

有模板

返回顶部
顶部