The problem lies here:
user=Clovek.objects.all().filter(user=user)
user=user[0]
just set a different variable name. Don't use the same for both.
You cannot loop over user
. the variable user in your code is set to user[0] which is not iterable. You need to loop over the query set Clovek.objects.all().filter(user=user)
so that it prints the result.
This will work:
users = Clovek.objects.all().filter(user=user)
for i in users:
print i
This won't work:
users = Clovek.objects.all().filter(user=user)
user = users[0]
for i in user: # user is not an iterable but users is.
print i
An example:
users = Clovek.objects.all().filter(user=user)
# in case there's only 1 result.
# user = users[0]
# you can access any of its field
# user.id, user.whatever
# in case there's more than 1:
for i in users:
print i.id