0

I'm having trouble getting MongoEngine to accept specific IDs. It seems absolutely determined to use (and only use) ObjectIds. I'm more than able to generate my own IDs in this instance, thanks.

How can I get MongoEngine to play nice?

Community
  • 1
  • 1
Noah McIlraith
  • 14,122
  • 7
  • 31
  • 35

1 Answers1

-2

I managed to solve this by adding the following to the class:

id = mongoengine.StringField(required=True, primary_key=True)

Not sure if this is the "proper" way of doing things, so ill leave this unanswered for a bit.

Noah McIlraith
  • 14,122
  • 7
  • 31
  • 35
  • What was your problem. What did you add to fix it? How would someone besides you comprehend your problem? Are you saying you didn't have any field acting as an id at all before and couldn't figure out why mongoengine wasn't allowing you to use an ad hoc id field? – Profane Aug 18 '11 at 01:30
  • I could specify the id field even if it wasn't specified, but it wouldn't accept a string/unicode id, only ObjectId. – Noah McIlraith Sep 03 '11 at 20:15
  • @NoahMcIlraith has this been resolved in later versions of mongoengine? I am currently using 0.9.0 and facing the same problem however this worked for me. – Arpit Goyal Jun 18 '17 at 06:59