when i try to serialize the list variable returned by the database query, an error of 'non-serializable is returned. But when i hardcode the same exact string in, or so it seems...serialization works. Any ideas why?
car_list = Car.objects.get(id=query).all_cars.values('id','name').order_by('name')
#car_list = [{'id': 9L, 'name': u"Porche"}, {'id': 6L, 'name': u'Toyota'}, {'id': 7L, 'name': u'Hugo'}, {'id': 3L, 'name': u'Honda'}]
data = { 'list':car_list }
print simpl开发者_如何转开发ejson.dumps(data)
simplejson cannot serialize Django types. Pass the result to list()
to turn it into something simplejson can serialize.
精彩评论