title: How to output Django queryset as JSON?
body: <p>I want to serialize my queryset, and I want it in a format as this view outputs:</p>
  <pre><code>class JSONListView(ListView):
      queryset = Users.objects.all()
  
      def get(self, request, *args, **kwargs):
          return HttpResponse(json.dumps({'data': [['bar','foo','bar','foo'],['foo','bar','foo','bar']]}, indent=4), content_type='application/json')
  </code></pre>
  <p>I simply don't know how to output the queryset instead of the manual data in the example.</p>
  <p>I've tried</p>
  <pre><code>json.dumps({&quot;data&quot;: self.get_queryset()})
  </code></pre>
  <p>and</p>
  <pre><code>serializers.serialize(&quot;json&quot;, {'data': self.get_queryset()})
  </code></pre>
  <p>but it won't work. What am I doing wrong? Do I need to make a custom JSON Encoder?</p>