title: python json serialize datetime
body: <p>First, a simple question on terms,<br>
  Encoding(<code>json.dumps</code>) means, converting something to json string,<br>
  decoding(<code>json.loads</code>) means, converting json string to json type(?)  </p>
  
  <hr>
  
  <p>I have a list of objects which I got from  </p>
  
  <pre><code>&gt;&gt;&gt; album_image_list = AlbumImage.objects.all().values(*fields)[offset:count]
  &gt;&gt;&gt; json.dumps(album_image_list[0], cls=DjangoJSONEncoder)
  '{"album": 4, "album__title": "g jfd", "created_at": "2012-08-18T02:23:49Z", "height": 1024.0, "width": 512.0, "url_image": "http://--:8000/media/101ac908-df50-42cc-af6f-b172c8829a31.jpg"}'
  </code></pre>
  
  <p>but when I try the same on whole list (album_image_list),it fails... </p>
  
  <pre><code>&gt;&gt;&gt; json.dumps(album_image_list, cls=DjangoJSONEncoder)
  Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.6/json/__init__.py", line 237, in dumps
      **kw).encode(obj)
    File "/usr/lib/python2.6/json/encoder.py", line 367, in encode
      chunks = list(self.iterencode(o))
    File "/usr/lib/python2.6/json/encoder.py", line 317, in _iterencode
      for chunk in self._iterencode_default(o, markers):
    File "/usr/lib/python2.6/json/encoder.py", line 323, in _iterencode_default
      newobj = self.default(o)
    File "/home/--/virtualenvs/aLittleArtist/lib/python2.6/site-packages/django/core/serializers/json.py", line 75, in default
      return super(DjangoJSONEncoder, self).default(o)
    File "/usr/lib/python2.6/json/encoder.py", line 344, in default
      raise TypeError(repr(o) + " is not JSON serializable")
  TypeError: [{'album': 4L, 'album__title': u'g jfd', 'created_at': datetime.datetime(2012, 8, 18, 2, 23, 49, tzinfo=&lt;UTC&gt;), 'height': 1024.0, 'width': 512.0, 'url_image': u'http://--:8000/media/101ac908-df50-42cc-af6f-b172c8829a31.jpg'}, {'album': 4L, 'album__title': u'g jfd', 'created_at': datetime.datetime(2012, 8, 18, 1, 54, 51, tzinfo=&lt;UTC&gt;), 'height': 512.0, 'width': 512.0, 'url_image': u'http://--:8000/media/e85d1cf7-bfd8-4e77-b90f-d1ee01c67392.jpg'}] is not JSON serializable
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>Why does it succeed on one element and fails on the list? </p>