Fix backwards compatibility with mongoengine < 0.7