【发布时间】:2021-12-31 15:05:35
【问题描述】:
我有 2 类用户,他们可以查看列出我的应用中所有用户的屏幕。用户类型由用户模型上的布尔字段控制。该屏幕当前列出了用户和有关他们的各种详细信息(见下文)。项目经理应该看到页面的只读视图,管理员也应该能够编辑用户。
屏幕的 HTML。
<div class="card-body">
<div class="table-responsive">
<table class="table text-sm mb-0">
<thead>
<tr>
<th>#</th>
<th>Username</th>
<th>First Name</th>
<th>Last Name</th>
<th>Is Contributor?</th>
<th>Is Project Manager?</th>
<th>Is is_administrator?</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<th scope="row">{{ user.id }}</th>
<td>{{ user.username }}</td>
<td><a class="btn btn-primary" href=" " role="button">{{ user.first_name }}</a></td>
<td>{{ user.last_name }}</td>
<td>{{ user.is_contributor }}</td>
<td>{{ user.is_projectmanager }}</td>
<td>{{ user.is_administrator }}</td>
<td><a class="btn btn-info" href="" role="button">Edit</a></td>
<td><a class="btn btn-danger" href="" role="button">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
我想创建一个可供管理员用户使用的屏幕版本,允许他们一次查看和更新所有用户。
如何创建一次更新所有用户的表单?我正在寻找构建的东西,列出与模型关联的字段列表的用户,然后让管理员能够同时为多个用户更改这些字段,然后点击保存按钮提交形式?
【问题讨论】:
标签: html django django-forms permissions crud