Is there a way I can serialize a FloatField model instance in django? I have the following in a management command:
def chart_data(request):
    i = 1
    chart = open_flash_chart()
    chart.title = t   
    for manager in FusionManagers.objects.all():
      net_data = manager.netio_set.values_list('Net', flat=True)
      clean = serializers.serialize('json', [ net_data, ])
      new = line()
      new.values = clean
      locals()["graph_" + str(i)] = new
      chart.add_element(locals()["graph_" + str(i)])
      i = i + 1
  return HttpResponse(chart.render())
But I get the error: 'ValuesListQuerySet' object has no attribute '_meta' The 'Net' fields are floatfields, and the values are filtered to 2 decimal places, so I get 400.23, etc...开发者_StackOverflow Can these be serialized?
The Django serialization module only works on lists/querysets of full Django objects;
ValuesListQuerySetcontains tuples, not Django objects.
I am quoting from a comment attached to Django ticket #8090. You'll need to get a QuerySet if you want to use Django's built in serialization. If not, you'll have to use a custom serializing module. 
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论