ジェネリックビューは指定したモデルから全レコードを取り出したり、特定のIDのものだけ取り出す基本的機能を持ったビュー
ListViewは全レコードを取り出すためのジェネリックビュー
DetailViewは特定のレコードを取り出すためのジェネリックビュー
### ジェネリックビューで表示
/hello/views.py
from django.views.generic import ListView from django.views.generic import DetailView class FriendList(ListView): model = Friend class FriendDetail(DetailView): model = Friend
/hello/urls.py
from .views import FriendList
from .views import FriendDetail
urlpatterns = [
path('', views.index, name='index'),
path('create', views.create, name='create'),
path('edit/<int:num>', views.edit, name='edit'),
path('delete/<int:num>', views.delete, name='delete'),
path('list', FriendList.as_view()),
path('detail/<int:pk>', FriendDetail.as_view()),
]
/hello/templates/hello/friend_list.html
<body class="container">
<h1 class="display-4 text-primary">Friends List</h1>
<table class="table">
<tr>
<th>id</th>
<th>name</th>
<th></th>
</tr>
{% for item in object_list %}
<tr>
<td>{{item.id}}</td>
<td>{{item.name}}</td>
<td><a href="/hello/detail/{{item.id}}">detail</a></td>
</tr>
{% endfor %}
</table>
</body>

/hello/templates/hello/friend_detail.html
<body class="container">
<h1 class="display-4 text-primary">Friends Detail</h1>
<table class="table">
<tr>
<th>id</th>
<th>{{object.id}}</th>
</tr>
<tr>
<th>name</th>
<th>{{object.name}}</th>
</tr>
<tr>
<th>mail</th>
<th>{{object.mail}}</th>
</tr>
<tr>
<th>gender</th>
<th>{{object.gender}}</th>
</tr>
<tr>
<th>age</th>
<th>{{object.age}}</th>
</tr>
</table>
</body>

なるほど