Reputation: 2576
i tried to save data into mongodb database using Mongoengine orm and flask, the problem is whene i save data then try to access data from saved object its given none
here is my view.py
s = Users(name="kaushik")
s.username = "kaushikmakwana"
data = s.save()
print(s) # output users object
print(data._id) #output None
print(data.id) #outeput None
here is my model.py
class Users(DynamicDocument):
meta = {'collection' : 'user'}
_id = StringField()
name = StringField()
username = StringField()
def __repr__(self):
return '<Users %r' % self.name
why its give None? how can i access this object data after saved?
Upvotes: 0
Views: 462
Reputation: 429
Delete _id from your model, this field is autogenerated from mongodb
Upvotes: 2