Python 找不到页面404 URL配置
当我试图查看主页时,我的终端(在运行服务器时)一直出现以下错误。 “GET/HTTP/1.1”404 2028 以下是我用于映射URL的代码: url.py(主): py(在学习日志文件夹中) views.py:Python 找不到页面404 URL配置,python,django,url,design-patterns,mapping,Python,Django,Url,Design Patterns,Mapping,当我试图查看主页时,我的终端(在运行服务器时)一直出现以下错误。 “GET/HTTP/1.1”404 2028 以下是我用于映射URL的代码: url.py(主): py(在学习日志文件夹中) views.py: from django.shortcuts import render def index(request): """The home page for learning log""" return render(request, 'learning_logs
from django.shortcuts import render
def index(request):
"""The home page for learning log"""
return render(request, 'learning_logs/index.html')
# Create your views here.
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p>Learning Log</p>
<p>Learning log helps you keep track of your learning, for any topic you're learning about.</p>
</body>
</html>
学习日志
学习日志可以帮助您跟踪您的学习情况,了解您正在学习的任何主题
这是我在主页上看到的错误:
Django使用learning_log.URL中定义的URLconf,按以下顺序尝试了这些URL模式:
管理员/
提前感谢您的帮助。我怀疑您的问题在于
url.py中的这一行
path(r'',包括('learning\u logs.url',namespace='learning\u logs'),
在正则表达式中不应该有空格
path(r'',include('learning_logs.url',namespace='learning_logs')),
都德我刚刚发现了这一点,正回来发布解决方案。谢谢你的帮助!
from django.shortcuts import render
def index(request):
"""The home page for learning log"""
return render(request, 'learning_logs/index.html')
# Create your views here.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p>Learning Log</p>
<p>Learning log helps you keep track of your learning, for any topic you're learning about.</p>
</body>
</html>