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

MongoEngine Python AttributeError

I am trying to use mongodb with my application, I have made a Player Class instance such as: class Player(mongoengine.Document): def __init__(self,name=None,hschool=None,gradclass=None,position=None, …
Tolga Oguz
  • 142
  • 1
  • 14
0
votes
1 answer

MongoEngine: Operator "__contains" does not work with non-english letters or words

When trying to use Q(nickname__contains="") from mongoengine.queryset.visitor, mongoengine will not match the non-english character. For instance: { "nickname":"你好啊" } => User.objects(Q(nickname__contains="你好")).first() => None But with English…
Lincoln Yan
  • 337
  • 1
  • 10
0
votes
1 answer

Query data in one queue to get a document with it's own actual version

I have a collection with several documents. The documents might look like this: {"brand" : "Mars", "version" : 1} {"brand" : "Mars", "version" : 2} {"brand" : "Bounty", "version" : 4} {"brand" : "Snickers", "version" : 3} I want to write a query…
Neal Mc Beal
  • 245
  • 3
  • 16
0
votes
1 answer

How to add a default filter parameter to every query in mongoengine?

I've been researching a lot, but I haven't found a way. I have Document clases with a _owner attribute which specifies the ObjectID of the owner, which is a per-request value, so it's globally available. I would like to be able to set part of the…
k-ter
  • 958
  • 1
  • 8
  • 20
0
votes
3 answers

How do I retrieve and print pymongo.cursor.Cursor objects?

I am creating a simple database CRUD manager using python and connecting it to a MongoDB database. I have connected to my cluster and have retrieved posts before using the exact same method. However this time when I tried, it does not work. The…
Jdevit
  • 1
  • 1
  • 2
0
votes
1 answer

How do I update if exist and insert if not using mongoengine (python)

It is really absurd how mongoengine has such arcane documentation. I am trying to do a simple (update if exists query) based on a few columns/fields. What I mean by that is if fieldA has valueA and fieldB has valueB and fieldC has valueC…
technazi
  • 888
  • 4
  • 21
  • 42
0
votes
1 answer

Can't catch exception inside create_view() in no-debug mode

I've overridden create_view() method inside my mongoengine.ModelView: from mongoengine.errors import NotUniqueError from pymongo.errors import DuplicateKeyError class MyView(mongoengine.ModelView): @expose('/create/', methods=('GET', 'POST')) …
PATAPOsha
  • 372
  • 3
  • 18
0
votes
1 answer

$group aggregation with $sum returns nothing

I have a query which runs as expected when it's directly executed in MongoDB, but I'm facing some troubles trying to make it work through MongoEngine. In fact, it returns nothing. Query on MongoDB (which works…
0
votes
1 answer

MongoEngine - Call function only when document is being created or specific field being set?

I'm not sure what is the best/pythonic way of having a User document that automatically hashes its password upon creating. Consider the following mongoengine model : class User(Document): email = EmailField(required=True, primary_key=True) …
Mojimi
  • 2,561
  • 9
  • 52
  • 116
0
votes
1 answer

Mongodb embedded document as a container for related fields

Is it ok to use mongodb embedded document to combine related fields together? Example: a document has fields creator_id and creator_language, is it possible to replace them with an embedded document creator, containing fields id and language without…
Sadderdaze
  • 304
  • 3
  • 14
0
votes
0 answers

Issue with Filters in Custom QuerySets mongoengine

I have a MongoEngine model Place class Place(Document): is_favorite = fields.BooleanField(default=False) name = fields.StringField(max_length=150) price_tier = fields.IntField(min_value=1, max_value=3) meta = { 'queryset_class':…
vignz.pie
  • 173
  • 2
  • 14
0
votes
1 answer

Query and group nested documents with mongoengine

I have kind of a dual question which is keeping me from proceeding for a while already. I have read lots of articles, checked stackoverflow numerous times and read again the docs of mongoengine but I can not find the answer which works for me. I am…
0
votes
2 answers

Mongoengine find document without a field

I need to find a document in the collection of Chat that contains no deal field. According to the documentation exists checks if the field exist, and first, is used to retrieve the first result, but the next…
Sadderdaze
  • 304
  • 3
  • 14
0
votes
1 answer

How to use order_by on booleanfield using mongoengine

I want to order the result of my mongoengine call on two different fields. Open. This has status True or False. I want this because I want to display the open questions first Opendate. Because I want to newest questions to show on top. Combined…
0
votes
1 answer

ListField(ReferenceField(x)) query mongoengine

i am trying to make a mongodb database , the code bellow has some of the database documents, i am trying to divide the models into two parts, a part on a common/models.py file where i put the abstract classes, the other part is on monitor/models.py…
A.Mahamedi
  • 353
  • 1
  • 2
  • 11