table 'roles_users' is already defined for this MetaData instance

前端 未结 11 996
执笔经年
执笔经年 2021-02-05 01:40

hello iam trying to get a currnet_user information in my views

and i include from users.models import *

then in my code return return current_user;

<         


        
11条回答
  •  终归单人心
    2021-02-05 02:04

    Its one year late but if someone doesn't find the solution in the given answers may be this can solve the problem -

    I had this same problem with my class which was inherited from db.Model (of flask_sqlalchemy).

    My code looked like this -

    class MasterDB(db.Model):
        __tablename__ = 'masterdb'
        __table_args__ = {'schema': 'schema_any'}
        ...
        ...
    

    Resolved it by specifying the abstract property to True in the class variable list. Add it in the class variable list like this and it should work -

    class MasterDB(db.Model):
        __tablename__ = 'masterdb'
        __table_args__ = {'schema': 'schema_any'}
        __abstract__ = True
    

提交回复
热议问题