0

I have this list of objects and I need to access the individual parameters inside a particular object. Any help?

[object1,object2,object3,object4,object5,object6]

When I try iterating through for loop it says Objects are not iterable

values[]
self.values=list(TestParameters.objects.filter(id=1))

for x in self.values:
   for y in x:
      print y
Abhinav
  • 31
  • 3

1 Answers1

1

Try this

values=[TestParameters.objects.filter(id = 1)]
for x in values:
    for y in x:
        print y 

If you want to iterate over Model instances Reference

Community
  • 1
  • 1
planet260
  • 1,384
  • 1
  • 14
  • 30
  • Its printing those objects multiple times instead of going inside those objects and printing the elements within – Abhinav Feb 27 '15 at 12:26
  • It will print the column representing the object. If you want to iterate the object parameters then please see the reference I provided. – planet260 Feb 27 '15 at 12:28
  • I will go through it and let you know. Thanks for sharing – Abhinav Feb 27 '15 at 12:32