Questions tagged [flask-pymongo]
75 questions
1
vote
1 answer
How to pull a nested Document
Referring to this Question, Now I want to remove dinner from Random Name 2, how can I do that:
Here's what i tried:
din_val = data[0]
condition = {
"username" : session['user']["username"],
f"likings.{din_val}" : {
"$exists" : True
…

Yashasvi Bhatt
- 325
- 3
- 14
1
vote
1 answer
Update single array item with matching id and one of the array element using Pymongo
Update a single array item with matching id and one of the array element using Pymongo
Tried few Pymongo commands one using array_filters(not sure whether this works with only 1 array level depth) but looks like nothing is updating even though there…

Anand
- 71
- 9
1
vote
0 answers
Trouble passing MongoDB document to HTML (Flask & Pymongo)
I am having trouble passing a document from my MongoDB database to an HTML file I have rendered using flask. My database is called users and has fields "_id", "name", "username", and "score" in it. I want to set up an HTML page for the profile of a…

rachelo
- 31
- 1
- 5
1
vote
1 answer
Error encountered while processing debian mongo packages
I uninstalled mongo from my ubuntu and tried to install it again but getting below error now
Errors were encountered while processing:
/var/cache/apt/archives/mongodb-org-server_4.2.7_amd64.deb
…

Ghana
- 63
- 8
1
vote
1 answer
PyMongo aggregation Not working with $max operator
My query is working fine on the mongo shell. But when running through pymongo is giving error. Can someone help me with this one.
db.collectioname.aggregate([
{ "$match": { "$and": [
{ "organization_id":…

Rupak Banerjee
- 135
- 1
- 3
- 11
1
vote
2 answers
"Inner join" like with MongoDB in Flask, Jinja
I'm trying to perform an 'inner join' like with two MongoDB collections using Flask.
I think I should be using $lookup to achieve this, and my route currently is:
@app.route("/perfumes")
def perfumes():
perfumes = mongo.db.perfumes.find()
…

Guillermo Brachetta
- 3,857
- 3
- 18
- 36
1
vote
1 answer
error in from flask_pymongo import PyMongo ModuleNotFoundError: No module named 'flask_pymongo'
i am facing this error, i also installed flask-pymongo library, but it stills showing an error, i tried many different ways, but its the same error when i am using it. is there any way to resolve it. also i am sharing my code below.
from flask…

Saad Alam
- 11
- 1
- 2
1
vote
2 answers
TypeError: Object of type 'Location' is not JSON serializable
i am using geopy library for my Flask web app. i want to save user location which i am getting from my modal(html form) in my database(i am using mongodb), but every single time i am getting this error:
TypeError: Object of type 'Location' is not…

vatsalay
- 469
- 1
- 9
- 21
1
vote
0 answers
how to loop through pymongo data?
so i have this mongodb data and i want to loop over this. i am using flask_pymongo, but i can't use mongodb data as python dictonaries.
mongodb data as list of dictinary
[{'_id': ObjectId('5d7fa9f7d760eb306123be52'), 'bookname': 'biology book',…

vatsalay
- 469
- 1
- 9
- 21
1
vote
1 answer
How to choose a default option out of few multiple options while creating document?
Since I am new to flask-pymongo. I want to design my database such that there are a few specific multiple options out of which one is chosen to be the default value. How do I do that?
I did not find any option to do that.
Example:
For the field…

Ayush Saxena
- 13
- 2
1
vote
1 answer
Flask-pymongo RuntimeError: Working outside of application context
I'm writing a program to read mongodb document based on id field using flask-pymongo. But I'm getting error, can anybody tell me where am I going wrong?
code:
from flask import Flask, make_response, jsonify
from flask_pymongo import PyMongo
from…

MSR
- 63
- 7
1
vote
1 answer
Flask-PyMongo query DB
I have a remote MongoDB with scraped data that I want to display via webpage in Flask, but it seems to be running into issues. I'm able to add to the DB without issue, but displaying data from the DB seems like an impossible feat. I'm at a loss…

plaintoast
- 59
- 6
1
vote
0 answers
flask_pymongo can't access mongodb with auth
I use Flask and Flask-Pymongo
from flask_pymongo import PyMongo
user = PyMongo(app, uri='mongodb://username:password@192.168.88.29:27018/user')
pymongo.errors.OperationFailure: Authentication failed.
But using Pymongo with same mongodb uri then…

pakachu
- 77
- 1
- 1
- 13
1
vote
1 answer
insert values through python api in mongodb
I am trying to insert values in mongodb using python api.
I have tried the following:
from flask import Flask
from flask import jsonify
from flask import request
from flask_pymongo import PyMongo
app = Flask(__name__)
app.config['MONGO_DBNAME'] =…

cherry
- 11
- 2
1
vote
1 answer
pymongo aggregate collection keys
Using this answer here https://stackoverflow.com/a/43570730/7626649
I'd like to do this with flask-pymongo.
Specifically I'd like to perform the below query in flask-pymongo and/or pymongo (It seems like if it can be done in one then it could be…

Sylv
- 41
- 1
- 8