[Answered ]-Django Querying MongoDB ObjectIds in views from json object

2đź‘Ť

âś…

According to this Using MongoDB with Django reference site:

Notice that to access the unique object ID, you use “id” rather than “_id”.

I tried revising the code from:

Line.objects(_id=ObjectId(_id.get('$oid'))).update(set__geometry=geometry, set__properties=properties)

to

Line.objects(id=ObjectId(_id.get('$oid'))).update(set__geometry=geometry, set__properties=properties)

…And it now works fine. Keeping this question for others who might need this.

👤Reiion

Leave a comment