0

I am working on mongoengine with Python3. I am trying to save one user at atime.

Users.objects.insert(user, load_bulk=False)

Printing this is giving me and ObjectId but still I am not able to see insert data in database.

Kartikeya Mishra
  • 118
  • 2
  • 10

1 Answers1

1

I have just been using the save() method. You can use it to save and update objects.

user = Users(
    parameter1="",
    parameter2="",
    parameter3="")
user.save()

To update I'll do this

user = User.objects.get(pk='ObjectId goes here')
user.parameter1 = ""
user.parameter2 = ""
user.parameter3 = ""
user.save()
Joseph Vargas
  • 772
  • 5
  • 17
  • Then that is strange. I just finished a whole rest api using these methods and everything is working perfectly. You're not getting any error messages whatsoever? – Joseph Vargas Jun 23 '18 at 07:33
  • You'll have to help others help you. You need to troubleshoot to narrow down the problem and provide more information. Check to see if your either sending/receiving the request data wrong, or if you didn't connect to the database correctly. With this little information, that's the best I can do. – Joseph Vargas Jun 25 '18 at 19:14
  • This was a silly mistake. Problem was that someone wrote table name without using underscore in between and I also did not added table name in model definition. – Kartikeya Mishra Jul 30 '18 at 12:40