MongoEngine/mongoengine — pull request #85 by psychogenic (2012-08-21 19:22:57+00:00)
Title: Minor bug fix to get "id_field" meta working

A derived class with an overloaded id() method was causing issues, so I used the "id_field" meta to get around it, setting up my class as

class Foo(orm.Document):
# avoid conflict between our library's expected id()
# method and the document's auto-gen'ed primary key (rename to uid)
meta = {'id_field':'uid'}

uid=orm.ObjectIdField(db_field='_id', name="uid")

# ....

However, this was failing with messages a-la:
mongoengine.base.ValidationError: > is not a valid ObjectId.

Fixed with a simple patch to fields.py (accessing the .pk, rather than hardcoding .id).

Regards,
Pat Deegan