0

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?

Kaushik Makwana
  • 2,422
  • 9
  • 31
  • 50

1 Answers1

2

Delete _id from your model, this field is autogenerated from mongodb

osmay88
  • 421
  • 3
  • 12