title: Use a custom ID type in mongodb usyng python
body: <p>Im using mongodb to as a storage backend for some of my information in a Django 1.5 app.</p>
  
  <p>Every document stored in the mongodb collection has an _id field which is a dict composed of several strings.
  Now when I try to retrieve this information I map the document to a model class using mongoengine:</p>
  
  <pre><code>from mongoengine import *
  
  class MyClass(Document):
      _id = DictField()
  </code></pre>
  
  <p>At the view I do:</p>
  
  <pre><code>documents = MyClass.objects
  print documents
  </code></pre>
  
  <p>When I call the view I get a <code>TypeError</code></p>
  
  <pre><code>TypeError at /viewname/
  id must be an instance of (str, unicode, ObjectId), not &lt;type 'dict'&gt;
  </code></pre>
  
  <p>Even worse is that when I use the save rutine</p>
  
  <pre><code>obj = MyClass({"tag":"sometag"})
  obj.save()
  </code></pre>
  
  <p>I get the exat same error, but at the db collection the document with <code>_id={"tag":"sometag"}</code> was created.</p>
  
  <p>Any ideas of what could be happening? It could be the same that is happening <a href="https://stackoverflow.com/questions/15500566/typeerror-at-accounts-login-id-must-be-an-instance-of-str-unicode-objectid"> here</a></p>
  
  <p>Note: I tried ussing the EmbeddedDocumentField but the results are the same (the error takes my Embedded class name instead of 'dict')</p>