flask-mongoengine

ListField is showing <ul> instead of <input> in edit/create post

隐身守侯 提交于 2019-12-10 18:54:59
问题 I am using Flask, mongoengine for a project and I am trying to get basic stuff working from http://docs.mongodb.org/manual/tutorial/write-a-tumblelog-application-with-flask-mongoengine/ After implementing everything from above link I added a new field for "tags" in Post and when I try to create a post, my tags doesn't show a input box. Any help is appreciated. My code and screenshot below class Post(db.DynamicDocument): created_at = db.DateTimeField(default=datetime.datetime.now, required

error while following Tumblelog Application with Flask and MongoEngine

风格不统一 提交于 2019-12-10 03:08:59
问题 I am following tumbleblog application here my __init__.py : from flask import Flask from flask.ext.mongoengine import MongoEngine app = Flask(__name__) app.config["MONGODB_SETTINGS"] = {'DB': "sencha_web_service", 'username': "<username>", "password": "<password>"} app.config["SECRET_KEY"] = "KeepThisS3cr3t" db = MongoEngine(app) if __name__ == '__main__': app.run() I get the error: mongoengine.connection.ConnectionError: Cannot connect to database default : False is not a read preference. I

Removing a column from a DictField in MongoDB [Flask + MongoEngine]

好久不见. 提交于 2019-12-08 10:10:39
问题 I need to remove a particular column (in this case "Paper ID") from a DictField (in this case "content") in all documents. The corresponding mongo-shell script for the same is db.list_input_file.update({},{$unset:{"content.Paper ID":1}}, false, true); How do I write the same thing using MongoEngine assuming that my model class is named JListInputFile. The documentation for the same isn't very helpful. 回答1: I think the issue you are having is a space in the field name meaning you can't pass it

python wtf AttributeError: 'ObjectIdField' object has no attribute 'help_text'

柔情痞子 提交于 2019-12-04 19:17:07
Based on this tutorial I am trying to create a form to get a few measurements. It seems that the part to display the data is working but when using the model_form command to generate the input form it breaks with this error: File "/myproject/lib/python3.4/site-packages/flask_mongoengine/wtf/orm.py", line 49, in convert 'description': field.help_text or '', AttributeError: 'ObjectIdField' object has no attribute 'help_text' The error happens on this line of my code: form_cls = model_form(Measurement, exclude=('id', 'created_at', 'comments')) This is my view.py code: from flask import Blueprint,

MongoClient opened before fork. Create MongoClient only Flask

女生的网名这么多〃 提交于 2019-12-02 06:50:31
I am running Flask with uwsgi threaded mode with processes 4 and using pymongo also flask_mongoengine and uwsgi says "MongoClient opened before fork. Create MongoClient only " I tried connect with connect=False but the result is same lazy-apps = true problem is fixed but it seems that uwsgi needs more time to load what can be done for best performance ? app.config['MONGODB_SETTINGS'] = {'DB': 'somedb', "USERNAME": "dbadmin", "PASSWORD":"somepass",'connect': False} And client = MongoClient(connect=False, username='dbadmin', password='somepass', authSource='somedb') Solutions for Mongoengine and

Get rid of Mongo $ signs in JSON

蹲街弑〆低调 提交于 2019-12-02 03:05:47
问题 I am building python backend for SPA (Angular) using MongoDB. Here is what I use: Python 3.4 , MongoDB 3 , Flask , flask-mongoengine and flask-restful Now I receive the following JSON from my backend: [ { "_id": { "$oid": "55c737029380f82fbf52eec3" }, "created_at": { "$date": 1439129906376 }, "desc": "Description.....", "title": "This is title" }, etc... ] And I want to receive something like that : [ { "_id": "55c737029380f82fbf52eec3", "created_at": 1439129906376, "desc": "Description....."

Get rid of Mongo $ signs in JSON

拟墨画扇 提交于 2019-12-02 01:18:51
I am building python backend for SPA (Angular) using MongoDB. Here is what I use: Python 3.4 , MongoDB 3 , Flask , flask-mongoengine and flask-restful Now I receive the following JSON from my backend: [ { "_id": { "$oid": "55c737029380f82fbf52eec3" }, "created_at": { "$date": 1439129906376 }, "desc": "Description.....", "title": "This is title" }, etc... ] And I want to receive something like that : [ { "_id": "55c737029380f82fbf52eec3", "created_at": 1439129906376, "desc": "Description.....", "title": "This is title" }, etc... ] My code for now: from flask import json from vinnie import app

MongoEngine Document Object made using from_json doesn't save

百般思念 提交于 2019-11-30 12:16:10
问题 I am trying to build a document object using from_json method. object.save() throws no error, but the document is not inserted in mongo. On the other hand if I make the object by assigning values to each of the fields, it works fine. I am unable to find the reason for this. Below is the code for both the cases. from flask import Flask from flask.ext.mongoengine import MongoEngine import json, datetime app = Flask(__name__) app.config["MONGODB_SETTINGS"] = {'DB': 'test','host': 'localhost'}

MongoEngine Document Object made using from_json doesn't save

守給你的承諾、 提交于 2019-11-30 02:24:44
I am trying to build a document object using from_json method. object.save() throws no error, but the document is not inserted in mongo. On the other hand if I make the object by assigning values to each of the fields, it works fine. I am unable to find the reason for this. Below is the code for both the cases. from flask import Flask from flask.ext.mongoengine import MongoEngine import json, datetime app = Flask(__name__) app.config["MONGODB_SETTINGS"] = {'DB': 'test','host': 'localhost'} app.config["SECRET_KEY"] = "mySecretKey" db = MongoEngine(app) class User(db.Document): user_id = db

Mongoengine: TypeError: __init__() got an unexpected keyword argument

不打扰是莪最后的温柔 提交于 2019-11-29 11:31:18
I am using flask-mongoengine extension and I have a User class like this: class User(db.Document, UserMixin): email = db.StringField(max_length=120, required=True, unique=True) password_hash = db.StringField(max_length=80, required=True) active = db.BooleanField() fb_id = db.StringField(max_length=120, required=False) def __init__(self, email, password, fb_id=None, active=True): hashp = md5.md5(password).hexdigest() self.email=email self.password_hash=hashp self.fb_id=fb_id self.active=active But when I do a simple get: User.objects.get(email = email) I get the error: TypeError: __init__() got