You needs rather some good tutorial instead of this answer.
HTML should have <form>
and <button>
to send selected group to server (ie. to other class GroupDetailView
), and serve should get in as argument using
re_path(r'^group/(?P<group_number>d+)$', views.GroupDetailView.as_view(), name='group-detail'),
and
class GroupDetailView(...):
def group_detail_view(request, group_number):
and use it to get persons from selected group
def group_detail_view(request, group_number):
persons = Person.objects.get(group=group_number)
and generate page with these person.
def group_detail_view(request, group_number):
persons = Person.objects.get(group=group_number)
return render(request, 'group_detail.html', context={'persons': persons})
All based on tutorial Django Tutorial Part 6: Generic list and detail views
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…