TypeError at /index Объект 'ModelBase' не является итерируемым в django?

Это мой файл index views, в котором я храню данные о таблице

def index(request):
if request.method == "POST" :
    for staffs in staff :
        stf_if = 'staff_id' + {{staffs.id}}
        staff_id = request.POST[stf_if]

        at_if = 'attendance' + {{staffs.id}}
        attendances = request.POST[at_if]

        date = datetime.date.today()

        ins = attendance(staff_id=staff_id, attendance=attendances, date=date)
        ins.save()

staffs = staff.objects.all()
attendances = attendance.objects.all()
amounts = amount.objects.all()
count_id = staff.objects.latest('id')
date = datetime.date.today()
return render(request, "salary/index.html", {'staff': staffs, 'attendance': attendances, 'amount': amounts, 'count_id': count_id, 'date': date})

здесь есть ошибки

for staffs in staff :

Это мой файл шаблона index.html, где находится форма

              <form action="/index" method="POST">
                                        {% csrf_token %}
                                        {% for staffs in staff %}
                                            <input type="hidden" name="staff_id{{staffs.id}}" value="{{staffs.id}}">
                                            <input type="hidden" name="attendance{{staffs.id}}" id='input_attendance{{staffs.id}}'>
                                            <tr>
                                                <td> {{staffs.id}} </td>
                                                <td> {{staffs.name}} </td>
                                                <td>
                                                    <div class="btn-group">
                                                        <button type="button" class="btn btn-outline-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id='present{{staffs.id}}'>
                                                            Present
                                                        </button>
                                                        <div class="dropdown-menu">
                                                            <a class="dropdown-item" onclick="attendance_present({{staffs.id}})">Present</a>
                                                            <a class="dropdown-item" onclick="attendance_absent({{staffs.id}})">Absent</a>
                                                            <a class="dropdown-item" onclick="attendance_half_day({{staffs.id}})">Half-day</a>
                                                        </div>
                                                    </div>
                                                </td>
                                                <td> {{staffs.role}} </td>
                                            </tr>
                                            
                                        {% endfor %}
                                        <tr>
                                            <button type="submit" style="float:right" class="btn btn-info">Save</button>
                                        </tr>
                                    </form>

Я новичок в django и в чем проблема я не понимаю, пожалуйста, помогите мне и заранее спасибо за помощь.

Вернуться на верх