我的 Django 管理页面显示未找到页面 (404)
My django admin page gives Page not found (404)
我的项目是 运行 好的,我使用了我的管理页面,今天一切正常,我试图打开它,但它显示找不到页面 (404)
没有产品匹配给定的查询。
请求方式:GET
请求 URL:http://127.0.0.1:8000/admin
提出者:store.views.product_detail
没有产品匹配给定的查询。
请求方式:GET
请求 URL:http://127.0.0.1:8000/admin
提出者:store.views.product_detail
我根本没碰过商店应用程序或项目文件,昨天醒来时一切正常,现在我无法访问管理页面
项目网址
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('store.urls', namespace='store')),
path('basket/', include('basket.urls', namespace='basket')),
path('account/', include('account.urls', namespace = 'account')),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
商店网址
from django.urls import path
from . import views
app_name = 'store'
urlpatterns = [
path('', views.product_all, name='product_all'),
path('<slug:slug>', views.product_detail, name='product_detail'),
path('shop/<slug:category_slug>/', views.category_list, name='category_list'),
]
店铺浏览量
from urllib import request
from django.shortcuts import get_object_or_404, render
from store.context_processors import categories
from .models import Category, Product
def product_all(request):
products = Product.products.all()
return render(request, 'store/home.html', {'products': products})
def category_list(request, category_slug=None):
category = get_object_or_404(Category, slug=category_slug)
products = Product.objects.filter(category=category)
return render(request, 'store/products/category.html', {'category': category, 'products': products})
def product_detail(request, slug):
product = get_object_or_404(Product, slug=slug, in_stock=True)
return render(request, 'store/products/single.html', {'product': product}) ```
context_processors.py 我已经将其包含在我的项目设置中
from .models import Category
def categories(request):
return {
'categories': Category.objects.all()
}
这是导致错误的代码
path('<slug:slug>', views.product_detail, name='product_detail'),
改为
path('detail/<slug:slug>/', views.product_detail, name='product_detail'),
product_detail
只是覆盖 admin
URL
我的项目是 运行 好的,我使用了我的管理页面,今天一切正常,我试图打开它,但它显示找不到页面 (404) 没有产品匹配给定的查询。 请求方式:GET 请求 URL:http://127.0.0.1:8000/admin 提出者:store.views.product_detail 没有产品匹配给定的查询。 请求方式:GET 请求 URL:http://127.0.0.1:8000/admin 提出者:store.views.product_detail
我根本没碰过商店应用程序或项目文件,昨天醒来时一切正常,现在我无法访问管理页面 项目网址
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('store.urls', namespace='store')),
path('basket/', include('basket.urls', namespace='basket')),
path('account/', include('account.urls', namespace = 'account')),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
商店网址
from django.urls import path
from . import views
app_name = 'store'
urlpatterns = [
path('', views.product_all, name='product_all'),
path('<slug:slug>', views.product_detail, name='product_detail'),
path('shop/<slug:category_slug>/', views.category_list, name='category_list'),
]
店铺浏览量
from urllib import request
from django.shortcuts import get_object_or_404, render
from store.context_processors import categories
from .models import Category, Product
def product_all(request):
products = Product.products.all()
return render(request, 'store/home.html', {'products': products})
def category_list(request, category_slug=None):
category = get_object_or_404(Category, slug=category_slug)
products = Product.objects.filter(category=category)
return render(request, 'store/products/category.html', {'category': category, 'products': products})
def product_detail(request, slug):
product = get_object_or_404(Product, slug=slug, in_stock=True)
return render(request, 'store/products/single.html', {'product': product}) ```
context_processors.py 我已经将其包含在我的项目设置中
from .models import Category
def categories(request):
return {
'categories': Category.objects.all()
}
这是导致错误的代码
path('<slug:slug>', views.product_detail, name='product_detail'),
改为
path('detail/<slug:slug>/', views.product_detail, name='product_detail'),
product_detail
只是覆盖 admin
URL