title: Using Flask's MongoEngine. Error with datetime field
body: <p>I have a model with the a datetime field </p>
  
  <pre><code>user_since = db.DateTimeField()
  </code></pre>
  
  <p>When I try to insert a new object of the model into mongo, There is no error. But the write does not succeed.</p>
  
  <p>I printed the object from to_json() and tried to insert it with mongo shell, I get the following error.</p>
  
  <pre><code>field names cannot start with $ [$date] at src/mongo/shell/collection.js:L147
  </code></pre>
  
  <p>the to_json had this field.</p>
  
  <pre><code>"user_since": {"$date": 1392205572989}
  </code></pre>
  
  <p>I can't seem to find any pointers on how to solve this.</p>
  
  <p>What is causing the write to fail?</p>
  
  <p>How can I make mongoengine to throw error in case of write failure.? Or at least find out what the error was?</p>
  
  <p>Thanks.</p>
  
  <p>Update:
  As I found later the real problem is not the datetime field. The details of the problem are in this question <a href="https://stackoverflow.com/questions/21731860/mongoengine-document-object-made-using-from-json-doesnt-save">MongoEngine Document Object made using from_json doesn&#39;t save</a></p>