title: serializing datetime with flasks tojson filter
body: <p>I'm getting this error:</p>
  
  <pre><code>TypeError: datetime.datetime(2012, 2, 12, 0, 47, 6, 542000) is not JSON serializable
  </code></pre>
  
  <p>when jinja is trying to parse this line:</p>
  
  <pre><code>var root_node_info = eval({{ nd|tojson|safe }});
  </code></pre>
  
  <p>nd contains a bson object from my mongo database. One of the fields is a datetime object. How can I get flask to serialize this properly?</p>
  
  <p>This is my mongokit model(in case its relevant)</p>
  
  <pre><code>class Item(Document):
      structure = {
          "tldr": unicode,
          "body": unicode,
          "user": unicode,
          "time_submitted": datetime.datetime,
          "upvotes": int,
          "downvotes": int,
          "tags": [unicode]
      }
  
      validators = {
      }
  
      indexes = [
          {'fields':['user']},
          {'fields':['tags']}
      ]
  
      use_dot_notation = True
  
      required_fields = ['body', 'user', 'time_submitted']
      default_values = {'time_submitted': datetime.datetime.utcnow}
  
      def __repr__(self):
          return '&lt;item %r&gt;' % (self._id)
  </code></pre>