Normaly在url.py文件中寻找一个url。如果找到了,则加载相关的HTML页面,如果找不到,则显示:带有msg的Page not found (404):
看到这个错误是因为Django设置文件中有DEBUG = True。将其更改为False,Django将显示一个标准404页。
我想改变django展示的标准404 page。我有一个创建了PageNotFound.html的HTML页面,我希望django在每次出现Page not found (404)时都显示DEBUG = False。我该怎么做?
我开始自己学习Django,理解URL和path是如何工作的有一个问题。
错误信息是:
找不到页面(404)
请求方法:获取
请求网址:http://127.0.0.1:8000/question/1/
使用在URLconf中定义的not_bad.urls,Django按照以下顺序尝试了这些URL模式:
名称=“索引”
名称=“结果”
微三亚/
当前路径问题/1/与其中的任何一个都不匹配。
在项目文件中我有以下代码:
not_bad\urls.py:
from django.contrib import admin
from django.urls import include
from dj
我正在学习一个教程,我一直在犯这些错误!为什么?我需要你的帮助。在错误页面上,上面写着"NoReverseMatch at /polls/反向查找参数'(1,)‘的详细信息’。1模式尝试:[‘/$/$(?P0-9+)/$’]“”请帮助,我正在努力完成本教程。教程链接“”
我的index.html
{% if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<li> <a href="{% url 'po
我的代码的问题是,当我试图点击我的帖子页面上的超链接时,我总是得到一个“页面找不到(404)错误,路径'post/...‘不匹配”。我发了3个帖子。会不会是正则表达式?因为我现在不擅长正则表达式。如何将views.py与the模式中的正确路径相匹配? 我的urls.py是: from django.contrib import admin
from django.urls import path, re_path
from blog import views as blog_views
urlpatterns = [
path('post/', blog_
ok民意测验教程已经完成,可以输入问题、投票等,但是从管理页面查看站点,也就是localhost:8000给予.
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
dose/
admin/
The empty path didn’t match any of these.
现在我有民意测验了.
fr
我在django有一个项目。在很多情况下,我:
raise Http404("this is an error")
它为我创建了一个很好的404页面,上面写着错误信息“这是一个错误”。
现在我想创建一个自定义错误页面,并让它仍然显示消息,但我不知道如何显示。
我确信它只是一个模板变量,我需要添加到我的自定义404模板中,但是我找不到它的任何文档。
下面是我使用Django创建的目录
isap/users需要从isap/isap/ templates /users/login.html获取模板
isap/
L isap
L templates
L users
L login.html
L ....
L ....
L .....
L ...
L users
L views.py
L urls.py
因此,我在settings.py和BASEDIR2 = os.path.dirname(os.path.dirname(os.p
问题
当尝试在website.com/robots.txt请求我的robots.txt文件时,我总是收到一个404错误。
文件
配置> urls.py
from django.conf import settings
from django.contrib import admin
from django.urls import path, include, re_path
from django.views.generic import TemplateView
from django.conf.urls.static import static
from config import