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
1 answer

How can I get current field value of a changed document in mongoengine?

When I change document I see field new value. But sometimes I want to see its old value (or it would be correctly say, its current value). I know that I can see changed fields in _changed_fields attribute and something tells me that I can see the…
egvo
  • 1,493
  • 18
  • 26
0
votes
2 answers

AttributeError: 'BaseQuerySet' object has no attribute 'is_authenticated'

I'm using flask-login and MongoDB as my database to store user profiles. When checking whether a user is authenticated in my login function: @bp.route('/login', methods=['GET', 'POST']) def login(): if current_user.is_authenticated: …
Mariusz
  • 2,617
  • 1
  • 23
  • 26
0
votes
0 answers

Django Rest + Mongoengine - Allow model fields to be optional

I've setup a REST api with django rest framework, using mongoengine for models. However, By default all the fields of model are mandatory but I want to make some of the fields as optional. my model.py is : class ProjectFormula(EmbeddedDocument): …
0
votes
0 answers

User login system in Django, with MongoDB as the primary database

So, here is the thing. I want the best method to log users on my website. I've already made a registration system that registers details of Users in the mongoDB using model forms. I don't understand how to login the user in th website. Do I fetch…
cyberhawk
  • 11
  • 5
0
votes
1 answer

How to query and get value from list in single document

I am trying to query a mongodb list in a single document. As shown below, I would like to match the code and get wheels value. if code = car then query should return wheels and allowed value for that list element. Below is a list from single…
user123987
  • 23
  • 5
0
votes
1 answer

How to know what fields have changed after updating?

I have been testing mongoengine. I want to update some fields of a document and know which ones have been changed using the pre_save method I have the following document from mongoengine import Document, StringField, EmailField, IntField,…
0
votes
1 answer

How to do atomic Read–modify–write in mongoengine?

Basically I have Post Document and Comment EmbeddedDocument as follow: class Comment(EmbeddedDocument): value1 = StringField(max_length=200,) value2 = StringField(max_length=200,) value3 = StringField(max_length=200,) id =…
adnanmuttaleb
  • 3,388
  • 1
  • 29
  • 46
0
votes
1 answer

match both field in EmbedDocuments

I need some help with mongoengine filtering please. What I am trying to do is to filter 2 fields in embed documents. I want both to match within the same document but I cannot figure out how to contain it that way. sample data: { "_id" : "1", …
Panupat
  • 452
  • 6
  • 21
0
votes
1 answer

Case insensitive sort in django rest framework with mongoengine

Django already has a way to achieve this for RDBMS: MyModel.objects.order_by(Lower('myfield')) I'm using DRF with mongoengine but the above throws error: TypeError: 'Lower' object is not subscriptable I'm guessing this is a bug in the way order_by…
Jai Sharma
  • 713
  • 1
  • 4
  • 17
0
votes
1 answer

Can't save Document once a new field added to the sub document. referenced using EmbeddedDocumentListField

I'm having a document and its sub-document, which works fine without changing anything which exists. When I add new field to the sub-document, while saving I got "you can only reference documents once they have been saved to the database" class…
Gopi P
  • 525
  • 9
  • 19
0
votes
1 answer

Use MongoDB server function in Python code as ID

I got some servers using Python to insert data to my MongoDB, since I want to read it from old --> new I want to get feedback by increasing number in ID. I'm using Mongoengine in my python code to insert, but didn't found any information about using…
XDavidT
  • 147
  • 15
0
votes
0 answers

Test cases are failing using mongomock pymongo mongoengine

I am trying to run test cases with mongomock having pymongo version as 2.X and mongoengine 0.10.6 I have tried to change the version for pymongo to 2.9.5 from 2.6.3 and mongoengine from 0.10.6 to 0.17.0. I have tried with mongomock from 3.0.0 to…
0
votes
1 answer

MongoEngine geo_within_box not working with polygon

I would like to query Drawing.objects(box__geo_within_box=[(-180, -90), (180, 90)]) Drawing.box being a polygon of this type PolygonField() initialized in the following way: { "type": "Polygon", "coordinates": [ [ [left, top], [right, top], [right,…
arthur.sw
  • 11,052
  • 9
  • 47
  • 104
0
votes
1 answer

How to convert Mongo DB query to Mongoengine

I have a Mongo DB query which needs to convert using MongoEngine. consider below query and I wanted to implement the same in MongoEngine ORM. I'm very much new to MongoDB and MongoEngine. thanks in advance db.my_collection.aggregate([ { …
Gopi P
  • 525
  • 9
  • 19
0
votes
1 answer

Mongoengine @property causes multiple loading of user model

I am adding several properties to my user model by the @property function. Basicaly what it does is doing a call to the cache to retrieve some data which is not in the DB. What I found was that when I am calling one of the attributes, set by…