为什么我的 table 值没有出现在 Django 模板中?
Why my table value is not showing up in django template?
我在视图中检索了我的 table,当我尝试在模板中使用它时没有显示任何内容。
这是我的观点文件
def index(request):
attendances = attendance.objects.all()
return render(request, "salary/index.html", {'attendance': attendances})
这是我的模板代码
{% for attendances in attendance %}
<th>{{attedances.id}}</th>
{% endfor %}
这是我的模型
class attendance(models.Model):
id = models.AutoField
staff_id = models.CharField(max_length=250, null=True)
attendance = models.CharField(max_length=250, null=True)
date = models.CharField(max_length=250)
attendances 的拼写错误。所以:
{% for attendances in attendance %}
<th>{{attendances.id}}</th>
{% endfor %}
我在视图中检索了我的 table,当我尝试在模板中使用它时没有显示任何内容。
这是我的观点文件
def index(request):
attendances = attendance.objects.all()
return render(request, "salary/index.html", {'attendance': attendances})
这是我的模板代码
{% for attendances in attendance %}
<th>{{attedances.id}}</th>
{% endfor %}
这是我的模型
class attendance(models.Model):
id = models.AutoField
staff_id = models.CharField(max_length=250, null=True)
attendance = models.CharField(max_length=250, null=True)
date = models.CharField(max_length=250)
attendances 的拼写错误。所以:
{% for attendances in attendance %}
<th>{{attendances.id}}</th>
{% endfor %}