table 'roles_users' is already defined for this MetaData instance

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

    My name is Jacob. I had the same situation.

    The issue is this: this occurs when you are importing parent and child tables in the same code. Then you import CHILD table, the CHILD table brings the parent table's structure also into the metadata. So you don't need to import PARENT table again.

    The solution is this: you would need to rearrange the order of importing the ORM structures in your code. The order is based on parent + child relation.

    Example: The following yields an error:

    import CHILD_ORM
    import PARENT_ORM   
    

    Rearrange the order as follows, to prevent the error:

    import PARENT_ORM   
    import CHILD_ORM
    

提交回复
热议问题