You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a huge internal dependance on the existence of "id" and "pk", such that if the field marked as primary_key weren't renamed, pretty much everything would explode.
Since your example here is… basically the stock default use for _id, there's a trick I use to allow for this kind of re-naming:
This assigns the gid attribute name to point at the actual _id field db-side. Note this is still a terrible idea. From the Zen of Python: there should be one, and preferably only one, right way to do something. Since MongoDB requires the primary key be called _id, why not stick to MongoEngine's default id (saving typing the _ all the time)?
if I have
gid = mongo.ObjectIdField(primary_key=True)
I can access it only using "id" or "pk", but not its own name.
The text was updated successfully, but these errors were encountered: