table 'roles_users' is already defined for this MetaData instance

前端 未结 11 975
执笔经年
执笔经年 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:15

    Just add extend_existing=True for roles_users as shown below

    # Define models
    roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
        db.Column('role_id', db.Integer(), db.ForeignKey('role.id')),
        extend_existing=True)
    

提交回复
热议问题