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
2 answers

How to make sorting in DB by the number of items in the ListField?

I have the next model: class Departments(Document): _id = fields.ObjectIdField() name = fields.StringField(blank=True, null=True) department_id = fields.StringField(blank=True, null=True) # Added list_of_users =…
TitanFighter
  • 4,582
  • 3
  • 45
  • 73
0
votes
1 answer

How do I connect to MongoDB v2.6.12 from Django 1.10 (python3.4) and pymongo v3.4?

I am new to Django, and I set up a mysites app using the tutorial given here I followed this guide to setup mongodb with Django using mongoengine However, I keep getting the following error everytime I try running the server: (myVirtEnv_1)…
sidx64
  • 426
  • 4
  • 10
0
votes
1 answer

Document Serializer returns object instead of id while using listfield of referencefield

I am using django 1.5.11 for mongodb. Serializer.data is returning objects instead of id for all references given in listfield. I am posting data in json format like this: { "author_id": ["5874a85b58c1d23a5343cc87","5874a85058c1d23a5343cc86"], …
0
votes
1 answer

making sure value exists with other value in mongoengine

I know mongoengine you can set things like unique_with but I want to set a constraint that says "if param_1 is True, param_2 must not be null." Is there a way to do this in mongoengine? Would the best way to handle this be to set conditions in the…
Rob
  • 3,333
  • 5
  • 28
  • 71
0
votes
2 answers

Python recursive import issue

I have a Python/Flask app that uses MongoEngine for the database. I have defined my models, and everything was working until the newest models were added. I believe the problem occurs because both models reference each other and it's causing a…
Jhorra
  • 6,233
  • 21
  • 69
  • 123
0
votes
1 answer

Execute code before creating document in mongoengine

How can I execute some code only when a document is created in mongoengine, not when updated. class Account(Document): name = StringField(max_length=80, default=None) username = StringField(max_length=60, required=True) created_at =…
Rohit Khatri
  • 1,980
  • 3
  • 25
  • 45
0
votes
1 answer

how to get data using using flask mongoengine

I am using mongoengine,flask and i am try to insert the data into db my code from flask import Flask,jsonify,request from flask_mongoengine import MongoEngine from mongoengine import connect app = Flask(__name__) app.config['MONGODB_DB'] =…
Ravi
  • 327
  • 1
  • 4
  • 14
0
votes
1 answer

python+django trying to serialize mongoengine documents to json but getting only arrays of fields names

I have the folowing model: class Estados(Document): Nome = StringField(max_length = 20, required=True) Sigla = StringField(max_length = 2, required=True) Cidades = ListField(StringField) When I'm querying it, with this method: from…
0
votes
1 answer

Python generalized update to child class

If I have a class like: class UpdateDocument(Document): modified_date = DateTimeField() meta = {'allow_inheritance': True} def save(self, *args, **kwargs): self.modified_date = datetime.utcnow() return…
Rob
  • 3,333
  • 5
  • 28
  • 71
0
votes
0 answers

Create collections in mongodb from django

Have a few question about mongodb with django! 1) What will be the best package/adaptor to use mongodb with django? 2) Can I create mongo collections without pre defining it's schema? like this one from pymongo import MongoClient client =…
subha.py
  • 463
  • 3
  • 18
0
votes
1 answer

Mongodb indexing error, field size

I am querying a collection and am receiving Btree::insert: key too large to index, failing. This is because I have an index on a Stringfield and the value is too big. I would like to query my db and simply throw away the ones that are too big but I…
Iluvatar14
  • 699
  • 1
  • 5
  • 18
0
votes
2 answers

Managing databases in Django models, sqlite and mongoengine

I'm developing some project in Django, something to manage assets in warehouses. I want to use two databases to this. First is sqlite database, which contains any data about users. Second is mongoDB database,in which want to store all the data…
0
votes
0 answers

mongengine (.10.6) does not save the Document

I have simple REST/json api. I am trying to update a mongoengine model Listing using a PUT call. I get one from the mongodb and update it using my own deserilize method with the incoming json. The update does not work as the json has a few DBRef and…
VRS
  • 1
  • 2
0
votes
1 answer

Mongoengine aggregate not working

I have the following code in mongonengine: Lend.objects.filter().aggregate( {"$group": {"_id": "$dni"}} ) But it doesn't work. I'm getting the followint output: http://pastebin.com/E82cVqXP Any ideas?
Jose Enrique
  • 361
  • 1
  • 3
  • 8
0
votes
1 answer

MapField is not displayed in Django Rest Framework Mongoengine

I have a model with following attributes. class File(DynamicDocument): country = fields.StringField(max_length=100, unique=True) languages = fields.MapField(fields.MapField( fields.EmbeddedDocumentField(AudioImage))) I am trying to…
Sijan Bhandari
  • 2,941
  • 3
  • 23
  • 36
1 2 3
99
100