title: Adding custom id field in flask/mongoengine document
body: <p>I am working on revamping an application from Django/MySQL to flask/mongo-engine &amp; am having trouble creating a model with an <code>id</code> field. This is a sample model:</p>
  
  <pre><code>class Location(db.Document):
      id = db.IntField(unique=True)
      name = db.StringField(max_length=200, required=True)
      # other fields in the document ...
  </code></pre>
  
  <p>For backward compatibility, I require the field <code>id</code> named as is. This used to work fine in MySQL but mongo-engine gives the ValidationError -- <code>Field is required: ['id'] Invalid Object ID: ['auto_id_0']</code> for documents of the above model.</p>
  
  <p>I also tried using the <code>db_field</code> parameter as in</p>
  
  <pre><code>id = db.IntField(db_field='l_id', unique=True)
  </code></pre>
  
  <p>...but to no avail.</p>
  
  <p><strong>Do note that I have no intentions of overriding the default <code>ObjectID</code> field of mongodb.</strong> Is there any workaround for this, other than renaming the field upon deserialization?</p>