Django中的TemplateDoesNotExist 异常

settings.py中的两个位置确认之后就ok了,分别是:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

原来的 'DIRS': [],改为 'DIRS': ['templates'],

TEMPLATE_DIRS = (
    # os.path.join(BASE_DIR,  'templates'),
    os.path.join(BASE_DIR, 'templates').replace('\\', '/'),
)

猜你喜欢

转载自wowlinda80.iteye.com/blog/2215441
今日推荐