Renamed Document._id to id (still _id in DB)
Although MongoDB uses _id, underscore prefixed attributes imply private access in Python and are sometimes may not be accessed (e.g. in the Django template language), but id should be public.
This commit is contained in:
parent
fc0e67023a
commit
0a64f42d5f
6 changed files with 23 additions and 23 deletions
|
|
@ -18,8 +18,8 @@ class Document(BaseDocument):
|
|||
"""Save the document to the database. If the document already exists,
|
||||
it will be updated, otherwise it will be created.
|
||||
"""
|
||||
_id = self.objects._collection.save(self.to_mongo())
|
||||
self._id = _id
|
||||
object_id = self.objects._collection.save(self.to_mongo())
|
||||
self.id = object_id
|
||||
|
||||
@classmethod
|
||||
def drop_collection(cls):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue