1π
β
The object is not iterable because :
ImageAndUser.objects.filter(user=request.user).order_by('id').last()
This filter condition returned only last object in the list. One resulting element is not iterable.
I suggest you modify your code and try to print the number of items in the query set.
def tc(request):
tcresults = ImageAndUser.objects.filter(user=request.user).order_by('id').last()
print tcresults, ' queryset'
print len(tcresults), ' length'
d = {
'tcresults': tcresults,
}
return render(request, 'registration/accounts/tc.html', d)
And update your html code like this :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>tc</title>
</head>
<body>
<h2>
γγγ{{ tcresults.tc }}
</h2>
</body>
</html>
π€Prakhar Trivedi
Source:stackexchange.com