[英]django 404 not found page
I am trying to show a blogpost on the site. 我正在尝试在网站上显示博客文章。
Below is details of urls
and view
file details but still it showing a 404 not found page
以下是
urls
详细信息和view
文件的详细信息,但仍显示404 not found page
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="ShopHome"),
path("blogpost/", views.blogpost, name="blogpost")
]
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def index(request):
return render(request, 'blog/index.html')
def blogpost(request):
return render(request, 'blog/blogpost.html')
Showing: 显示:
404 not found page
找不到404页面
you should include urls.py
of your application to project urls.py
你应该包括
urls.py
您的应用程序项目的urls.py
actually if your project name is " mysite
" and your application name is " blogspot
", you should include mysite/blogspot/urls.py
on this file mysite/mysite/urls.py
like this: 实际上,如果您的项目名称为“
mysite
”,而您的应用程序名称为“ blogspot
”,则应在此文件mysite/mysite/urls.py
包含mysite/blogspot/urls.py
,如下所示:
from django.urls import path, include
urlpatterns = [
path('', include('blogspot.urls')),
]
实际上,我忘记在URL中注册此应用程序的URL时添加斜杠
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.