title: django webapi: dump django model to JSON
body: <p>I'm trying to dump django models into JSON format. I've tried to do it like this:</p>
  
  <pre><code>import json
  from api.models import User
  from django.http import HttpResponse
  
  def users(request):
      users = User.objects.all()
      return HttpResponse(json.dumps(users), content_type="application/json")
  </code></pre>
  
  <p>but it throws following error:</p>
  
  <pre><code>[&lt;User: Paul McCartney&gt;, &lt;User: John Lennon&gt;, &lt;User: George Harrison&gt;, &lt;User: Ringo Starr&gt;] is not JSON serializable
  </code></pre>
  
  <p>I know I can iterate through all objects and create a manual list of dictionaries, but I hope there's any better way to do that. Is there?</p>