Parth Jeet
Parth Jeet

Reputation: 129

django : 'Manager' object is not iterable

I'm trying to make a table getting data from models. But I'm getting this error :

TypeError at /main/
'Manager' object is not iterable

Template File:

3   <head>
4       <meta charset="UTF-8">
5       <title>Acc</title>
6   
7   </head>
8   <body>
9       <h1>The Values are:</h1>
10      {% if main %}
11  
12          <table>
13                  {% for obj in main %}
14                      <tr>
15                          <td>{{ obj.isTremor }}</td>
16                          <td>{{ obj.isFall }}</td>
17                      </tr>
18                  {% endfor %}
19          </table>
20  
21      {% endif %}
22  </body>
23  </html>

I'm sorry if this is a very absic question, but I'm very new to this. Thanks

EDIT 1 :

View that renders this :

def main(request):
    acc_list = AccModel.objects
    acc_dict = {'main': acc_list}
    return render(request, 'appTwo/main.html', context=acc_dict)

URL :

url(r'^main/', views.main, name='main'),

Upvotes: 0

Views: 1065

Answers (1)

Lemayzeur
Lemayzeur

Reputation: 8525

all() is missing

def main(request):
    acc_list = AccModel.objects.all() #you had missed the .all()
    acc_dict = {'main': acc_list}
    return render(request, 'appTwo/main.html', context=acc_dict)

Upvotes: 3

Related Questions