【发布时间】:2020-07-15 22:09:00
【问题描述】:
我想在我的模板中显示所有用户,但我收到了这个错误。 /list/ 处的类型错误 init() 接受 1 个位置参数,但给出了 2 个
views.py
class UsersView(TemplateView):
template_name = 'list.html'
context = super(UsersView, self).get_context_data(**kwargs)
context['object_list'] = User.objects.values()
list.html
<tbody>
<tr>
<th scope="col">Id</th>
<th scope="col">username</th>
<th scope="col">email Adress</th>
<th scope="col">First Name </th>
<th scope="col">Last Name</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.id }} </td>
<td>{{ user.username}}</td>
<td>{{ user.email }}</td>
<td>{{ user.first_name}}</td>
<td>{{ user.last_name }}</td>
如何拉动所有用户?
【问题讨论】:
标签: django django-views