Почему значение моей таблицы не отображается в шаблоне django?
Я получил свою таблицу в представлениях, но когда я попытался использовать ее в шаблоне, она ничего не показывает.
Это мой файл представлений
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)
У вас опечатка в написании посещаемости. Итак:
{% for attendances in attendance %}
<th>{{attendances.id}}</th>
{% endfor %}