Questions tagged [mongoengine]

MongoEngine is a Document-Object Mapper (think ORM, but for document databases) for working with MongoDB from Python. It uses a simple declarative API, similar to the Django ORM.

MongoEngine is a Document-Object Mapper (think ORM, but for document databases) for working with MongoDB from Python. It uses a simple declarative API, similar to the Django ORM.

1823 questions
0
votes
3 answers

No module named flask_mongoengine

I'm having a problem importing flask-mongoengine. The error I'm getting is: ImportError: No module named flask_mongoengine I am using a virtual environment (installed using sudo), with the following…
0
votes
1 answer

Trying to upsert document in flask_MongoEngine

I've currently got a model: class Ticket(db.Document): name = db.StringField #issue.key project = db.StringField() #issue.fields.project.key issue_type = db.StringField() #issue.fields.issuetype.name summary = db.StringField()…
LConnor
  • 13
  • 4
0
votes
1 answer

update() function disregards limit() in mongo

Lets say I have a 10 documents of Item in the database. Lets retrieve 3 documents of Item matching some condition using limit(). documents = Item.objects(somefield=somecondition).limit(3) Now if I do documents.update(), mongoengine updates all the…
Sri Hari Vignesh
  • 256
  • 4
  • 11
0
votes
4 answers

ImportError: No module named rest_framework_mongoengine

I have installed both DjangoRest framework and Mongo Engine using pip, included rest_framework_mongoengine in INSTALLED_APPS list. Still exception is being thrown when I run server. File…
NightFury
  • 13,436
  • 6
  • 71
  • 120
0
votes
1 answer

Correctly Call __set__ in MongoEngine Document constructor

I'm intending to store Pandas DataFrames in MongoDB using the Python MongoEngine framework; coercing Pandas Dataframes to a Python Dict via df.to_list() and storing them as a nested Document attribute. I'm attempting to minimize the amount of code…
Jthorpe
  • 9,756
  • 2
  • 49
  • 64
0
votes
1 answer

Finding best match in mongoengine database with Django

Suppose we have a a Django model similar to this: from mongoengine import (Document, StringField, DateTimeField) class MyModel(Document): car = StringField() plane = StringField() name = StringField() some_field = SecretField() …
Photon Light
  • 757
  • 14
  • 26
0
votes
1 answer

save() doesn't update datetime fields in monoengine

I am new to mongoengine, but this doesn't make any sense to me, that when I call my my_update() function, the user's updated_at field doesnt get updated but other fields do. here is my model: class User(db.Document): username =…
Medya Gh
  • 4,563
  • 5
  • 23
  • 35
0
votes
0 answers

How do you delete mongo objects with mongoengine when model has changed?

I'm using MongoEngine and have a model that I just updated. I want to delete the old version of the objects in mongodb and insert some entries using the new version of the Model. Currently with mongoengine it looks like I can only act on the…
Visitor Ryan
  • 13
  • 1
  • 2
0
votes
0 answers

How to get the latest record on MongoEngine?

So if a user access a file, this creates a link which is accessible for 3 minutes. On my MongoDB the fields are. page_link:'link_to_file1', date_expires: ISODate("2017-06-14T04:30:39.380Z") So when the user access the same file, again. I'll check…
Julio de Leon
  • 1,032
  • 3
  • 14
  • 30
0
votes
1 answer

Read MongoEngine DynamicDocuments

my issue is that I am saving dict objects with MongoEngine: class MongoRecord(DynamicDocument): record_id = SequenceField(primary_key = True) class SimpleMongo(object): def __init__(self, *args, **kwargs): """ Very simple…
Pavel M.
  • 610
  • 1
  • 8
  • 24
0
votes
2 answers

What is universal method for `get or default` in python?

I would like to get an attribute of mongoengine model object but it's missing (how it's often in mongo): unit.city gives me AttributeError unit.get('city') says that 'Unit' object has no attribute 'get' and I can't find any appropriate method by…
egvo
  • 1,493
  • 18
  • 26
0
votes
1 answer

Reverse_delete_rule circular import

If I have two models, User and Address, and they reference each other like this: # usermodel.py from address import Address from mongoengine import * class User(Document): name = StringField() address = ReferenceField(Address) #…
Rob
  • 3,333
  • 5
  • 28
  • 71
0
votes
1 answer

MongoEngine: Appending ListField

I'm creating a database to store all trades made in a portfolio, which are segregated by individual "strategies". As shown in the code below, what are the drawbacks of appending new contracts/trades to the ListFields as a way of adding…
Duff
  • 410
  • 2
  • 13
0
votes
1 answer

_id is given None after saving data into model Mongoengine

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 =…
Kaushik Makwana
  • 2,422
  • 9
  • 31
  • 50
0
votes
1 answer

Mongoengine Document resets value of attribute after multiprocessing map

I have a large list of elements ~ 100000 and need to map it as follows: def mark_diff(args): item = args[0] pi = args[1] item.marked_diff = (item.p/pi[0]+item.c/pi[1]+item.f/pi[2] - 3)**2 return item def mark(f_set , goal): with…
xssChauhan
  • 2,728
  • 2
  • 25
  • 36