[Answered ]-TypeError at /check 'ModelBase' object is not iterable in django

1👍

You are using queryset object to fetch class’s attribute. It needs an instance to use class’s attribute. Just change your check method to the following:

def check(request):
    dishs = dish.objects.all()
    for dish in dishs:
        print(dish.dish_name)
    params = {'dish': dishs}
    return render(request, 
    "card/check.html", params)

Leave a comment