解决办法:在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',
            ],
        },
    },
]

 

相关文章:

  • 2022-12-23
  • 2021-09-08
  • 2021-10-13
  • 2022-12-23
  • 2021-09-13
  • 2021-12-05
  • 2021-09-17
  • 2021-04-07
猜你喜欢
  • 2021-09-08
  • 2022-12-23
  • 2021-09-08
  • 2021-09-27
  • 2021-06-16
  • 2021-07-29
  • 2021-09-08
相关资源
相似解决方案