1. 程式人生 > >Django 找不到模版報錯" django.template.exceptions.TemplateDoesNotExist: index.html"

Django 找不到模版報錯" django.template.exceptions.TemplateDoesNotExist: index.html"

解決辦法:在setting.py的TEMPLATES‘DIRS'[]加入模版路徑

 
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        #os.path.join(BASE_DIR, 'templates')沒了這句,
        # 會顯示django.template.exceptions.TemplateDoesNotExist: index.html
'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
', ], }, }, ]