<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Customer of the Harbin Grocery Website </title>
</head>
<body>
<h1>Customer List</h1>
<table border='1' style='border-collapse:collapse'>
{% for customer in customers_list %}
<tr>
<td>
{{customer.firstname}}
</td>
<td>
{{customer.lastname}}
</td>
<td>
{{customer.address}}
</td>
</tr>
{% endfor %}
</table>
</body>
</html>
from django.views.generic import TemplateView, ListView
from .models import Customer
class HomePageView(TemplateView):
template_name = "home.html"
class AboutPageView(TemplateView):
template_name = "about.html"
class ContactPageView(TemplateView):
template_name = "contact.html"
class CustomerView(ListView):
model=Customer
template_name = "customer.html"
from django.urls import path
from .views import HomePageView, AboutPageView, ContactPageView, CustomerView
urlpatterns = [
path("", HomePageView.as_view(), name="home"),
path("about/", AboutPageView.as_view(), name="about"),
path("contact/", ContactPageView.as_view(), name="contact"),
path("customer/", CustomerView.as_view(), name="customer"),
]
相似问题