title: Django serialize datetime to json in QuerySet/Dict
body: <p>I've tried to serialize <code>QuerySet</code> or <code>Dict</code> object with <code>datetime.date</code> object in the following ways: </p>
  
  <p><strong>Way #1:</strong></p>
  
  <pre><code>json.dumps(MyModel.objects.values())
  </code></pre>
  
  <p>Raises error:</p>
  
  <blockquote>
    <p>Exception Value: [{'date': datetime.date(2012, 5, 26), 'time':
    datetime.time(0, 42, 27)}] is not JSON serializable</p>
  </blockquote>
  
  <p><strong>Way #2:</strong></p>
  
  <pre><code>json.dumps(MyModel.objects.values(), cls=DjangoJSONEncoder)
  </code></pre>
  
  <p>Also raises error:</p>
  
  <blockquote>
    <p>Exception Value: [{'date': datetime.date(2012, 5, 26), 'time':
    datetime.time(0, 42, 27)}] is not JSON serializable</p>
  </blockquote>
  
  <p><strong>Way #3:</strong></p>
  
  <pre><code>json.dumps(MyModel.objects.all(), cls=DjangoJSONEncoder)
  </code></pre>
  
  <p>Exception Value: [&lt; MyModel: MyModel object>] is not JSON serializable</p>
  
  <p><strong>Way #4:</strong></p>
  
  <pre><code>serializers.serialize('json', MyModel.objects.all())
  </code></pre>
  
  <p>Raises error:</p>
  
  <blockquote>
    <p>Exception Value: 'str' object has no attribute '_meta'</p>
  </blockquote>
  
  <p><em>How to serialize object with  datetime's field to JSON in Django?</em></p>