我是Django的新手,正在从事一个项目。在我的项目中,管理员有权将项目分配给经理。因此,我想从数据库中呈现所有经理的姓名,以便将其显示给管理员。
这是我的.html
文件,我要在其中呈现管理器的名称:
<div class="body table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>S No.</th>
<th>COMPANY NAME</th>
<th>TEAM MEMBER</th>
<th>EMAIL</th>
<th>ASSIGN TEAM</th>
</tr>
</thead>
<tbody>
{%for team in object%}
<tr>
<form id="form_id" method="POST" action = "{% url 'accept' %}">
{% csrf_token %}
<th scope="row"> {{ forloop.counter }}</th>
<td>{{team.company_name}}</td>
<td>{{team.team_member}}</td>
<td>{{team.email}}</td>
<td>
<select name="manager">
{% for manager in managers %}
<option value ="{{manager.id}}">{{manager.name}}</option>
{% endfor %}
</select>
<!-- </div> -->
</td>
</tr>
{% endfor %}
</tbody>
</table>
这是我的经理模型:
class manager(models.Model):
name = models.CharField(max_length= 500)
designation = models.CharField(max_length= 500)
class Meta:
permissions = [
("edit_task", "can edit the task"),
]
def __str__(self):
return self.name
这是我的views.py
;
def accept(request):
obj= Create_Team.objects.filter(status='Accept')
if request.method == 'POST':
acc = manager()
manager_id = int(request.POST.get('manager', 1))
acc.manager = manager.objects.get(pk=manager_id)
return render(request, "admin/accept.html", {"object": obj})
在admins页面中,我想显示所有经理的姓名。我已经添加了管理页面的图像。
答案 0 :(得分:0)
我认为您忘记在上下文变量中包含 server.tomcat.basedir=/var/tomcat
server.tomcat.accesslog.buffered=true
server.tomcat.accesslog.directory=/access/log
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %{X-Forwarded-For}i %l %u %t "%r" %s %b
server.tomcat.accesslog.prefix=tomcat_access_log
查询集
managers