【发布时间】:2020-05-18 06:49:34
【问题描述】:
我正在尝试建立一个电子商务网站,但由于上面显示的错误,我可以继续。谢谢
url.py 文件
from django.urls import path
from .**views import ItemDetailView, HomeView, checkout
app_name = 'core'
urlpatterns =[
path('', HomeView.as_view(), name='homepage'),
path('checkout/', checkout, name='checkout'),
path('product/<slug>/', ItemDetailView.as_view(), name='product')
views.py 文件
from django.shortcuts import render
from .models import Item
from django.views.generic import ListView, DetailView
class HomeView(ListView):
model = Item
template_name = "home-page.html"
class ItemDetailView(DetailView):
model = Item
template_name = "product-page.html"
def checkout(request):
return render(request, 'checkout-page.html')
html模板
<a class="nav-link waves-effect" href="{% url 'core:product' %}" target="_blank">Products</a>
【问题讨论】: