librelist archives

« back to archive

Flask-SQLAlchemy or Flask-MongoEngine and PyCharm autocomplete problem

Flask-SQLAlchemy or Flask-MongoEngine and PyCharm autocomplete problem

From:
dorian i
Date:
2012-06-02 @ 11:23
Hi im using flask-sqlalchemy and flaks-mongoengine with pycharm. The
problem is that i don't have autocomplete on nearly anything. My code
snipets are by the documentation so i'm not doing anything different. Do
you know what configuration should i change or something?. Examples:

#SQLAlchemy example
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)

    def __init__(self, username, email):
        self.username = username
        self.email = email

    def __repr__(self):
        return '<User %r>' % self.username

#Mongoengine example

from flask import Flaskfrom flask.ext.mongoengine import MongoEngine
app = Flask(__name__)app.config.from_pyfile('the-config.cfg')db =
MongoEngine(app)

class User(db.Document):
    email = db.StringField(required=True)
    first_name = db.StringField(max_length=50)
    last_name = db.StringField(max_length=50)

Re: [flask] Flask-SQLAlchemy or Flask-MongoEngine and PyCharm autocomplete problem

From:
Jonathan Chen
Date:
2012-06-02 @ 15:38
I use pycharm also, and its a great tool. But you'll have problems with
dealing with flask extensions and plugins for autocomplete. I think its
because there is a lot of magic imports that happen that make it difficult
for Pycharm to catch it all. Any IDE is going to have this problem with
Python.

~Jonathan C.


On Sat, Jun 2, 2012 at 4:23 AM, dorian i <dorian.hoxha@gmail.com> wrote:

> Hi im using flask-sqlalchemy and flaks-mongoengine with pycharm. The
> problem is that i don't have autocomplete on nearly anything. My code
> snipets are by the documentation so i'm not doing anything different. Do
> you know what configuration should i change or something?. Examples:
>
> #SQLAlchemy example
> from flask import Flask
> from flask_sqlalchemy import SQLAlchemy
> app = Flask(__name__)
> app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
> db = SQLAlchemy(app)
>
>
> class User(db.Model):
>     id = db.Column(db.Integer, primary_key=True)
>     username = db.Column(db.String(80), unique=True)
>     email = db.Column(db.String(120), unique=True)
>
>     def __init__(self, username, email):
>         self.username = username
>         self.email = email
>
>     def __repr__(self):
>         return '<User %r>' % self.username
>
> #Mongoengine example
>
> from flask import Flaskfrom flask.ext.mongoengine import MongoEngine
> app = Flask(__name__)app.config.from_pyfile('the-config.cfg')db = 
MongoEngine(app)
>
> class User(db.Document):
>     email = db.StringField(required=True)
>     first_name = db.StringField(max_length=50)
>     last_name = db.StringField(max_length=50)
>
>
>

Re: [flask] Flask-SQLAlchemy or Flask-MongoEngine and PyCharm autocomplete problem

From:
dorian i
Date:
2012-06-02 @ 16:13
Looks like Flask-Peewee uses something different.

from flask import Flask
from flask_peewee.auth import Authfrom flask_peewee.db import Database
app = Flask(__name__)db = Database(app)*import* datetimefrom peewee import *

# needed for authentication

auth = Auth(app, db) class Note(db.Model): message = TextField() created =
DateTimeField(default=datetime.datetime.now)

He uses db.Model on the class but then uses TextField() and not
db.TextField(). Tried the same thing with mongoengine and it also worked.
You see any problem with this way?
On Sat, Jun 2, 2012 at 5:38 PM, Jonathan Chen <tamasiaina@gmail.com> wrote:

> I use pycharm also, and its a great tool. But you'll have problems with
> dealing with flask extensions and plugins for autocomplete. I think its
> because there is a lot of magic imports that happen that make it difficult
> for Pycharm to catch it all. Any IDE is going to have this problem with
> Python.
>
> ~Jonathan C.
>
>
>
> On Sat, Jun 2, 2012 at 4:23 AM, dorian i <dorian.hoxha@gmail.com> wrote:
>
>> Hi im using flask-sqlalchemy and flaks-mongoengine with pycharm. The
>> problem is that i don't have autocomplete on nearly anything. My code
>> snipets are by the documentation so i'm not doing anything different. Do
>> you know what configuration should i change or something?. Examples:
>>
>> #SQLAlchemy example
>> from flask import Flask
>> from flask_sqlalchemy import SQLAlchemy
>> app = Flask(__name__)
>> app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
>> db = SQLAlchemy(app)
>>
>>
>> class User(db.Model):
>>     id = db.Column(db.Integer, primary_key=True)
>>     username = db.Column(db.String(80), unique=True)
>>     email = db.Column(db.String(120), unique=True)
>>
>>     def __init__(self, username, email):
>>         self.username = username
>>         self.email = email
>>
>>     def __repr__(self):
>>         return '<User %r>' % self.username
>>
>> #Mongoengine example
>>
>> from flask import Flaskfrom flask.ext.mongoengine import MongoEngine
>> app = Flask(__name__)app.config.from_pyfile('the-config.cfg')db = 
MongoEngine(app)
>>
>> class User(db.Document):
>>     email = db.StringField(required=True)
>>     first_name = db.StringField(max_length=50)
>>     last_name = db.StringField(max_length=50)
>>
>>
>>
>