在实践python三剑客(第一本书:从入门到实践)第三个项目的时候,按照书上的代码复现,但是跟着打开网页的时候,发现报错
TemplateDoesNotExist at /
learning_logs/index.html
源文件找不到
view.py
from django.shortcuts import render
def index(request):
return render(request, 'learning_logs/index.html')
index.html
{% extends "learning_logs/base.html" %}
{% block content %}
Learning Log helps you keep track of your learning, for any topic you're learning about.
{% end block content %}base.html
{% block content %}{% end block content %}
TemplateDoesNotExist at /
learning_logs/index.html
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 4.0.4
Exception Type: TemplateDoesNotExist
Exception Value:
learning_logs/index.html
Exception Location: F:\learning_log\ll_env\lib\site-packages\django\template\loader.py, line 19, in get_template
Python Executable: F:\learning_log\ll_env\Scripts\python.exe
Python Version: 3.10.2
希望能复现书上的内容,能成功找到文件,网页正常化,不报错
有肯能是模板文件配置不对django无法搜索到,建议你自己看下书中关于模板文件夹Template有关内容,