Django 找不到模版报错" django.template.exceptions.TemplateDoesNotExist: index.html"

解决办法:在setting.py的TEMPLATES‘DIRS'[]加入模版路径

1

="font-size: 15px; color: #ff0000;">os.path.join(BASE_DIR, 'templates')</span>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

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',

            ],

        },

    },

]

转载:https://www.cnblogs.com/alan-babyblog/p/5828026.html 

你可能感兴趣的:(Python)