0
res= table.objects.values('lat','lng')
res1 = table1.objects.values('lat','lng')

res1=[{'lat': u'22.216021036729217', 'lng': u'84.83377508819103'}]
res=[{'lat': u'15.898394035175443', 'lng': u'73.82306920364499'}]

I want to add result of res and res1 into poi:

poi = [{'lat': u'15.898394035175443', 'lng': u'73.82306920364499'},{'lat': u'22.216021036729217', 'lng': u'84.83377508819103'} ] 

I have tried poi=list(res)+list(res1) but got the following error:

list referenced before assignment
Michael0x2a
  • 58,192
  • 30
  • 175
  • 224
  • see this [example](http://stackoverflow.com/questions/431628/how-to-combine-2-or-more-querysets-in-a-django-view) – kartheek Sep 18 '13 at 06:41

1 Answers1

0

You can use list operator to convert ValuesQuerySet into list

res= table.objects.values('lat','lng') res1 = table 1.objects.values('lat','lng')

poi = list(res) + list(res1)
  • that is exactly what i am doing but i get "list referenced before assignment" error –  Sep 18 '13 at 06:47
  • This is not giving me any error , I tried it. Can you please write down the exact code you are using. – Mohit Bagga Sep 18 '13 at 06:50
  • Or try to do this. poi = list(django_query1) + list(django_query2) – Mohit Bagga Sep 18 '13 at 06:52
  • the thing i was trying and you suggested was right, turned out i had a variable named "list" because of which was getting the error –  Sep 18 '13 at 09:03