sevenQu
V2EX  ›  Flask

flask, models 文件夹内的数据库模型文件,引用失败,求解?

  •  
  •   sevenQu · Mar 20, 2018 · 2398 views
    This topic created in 2976 days ago, the information mentioned may be changed or developed.

    • 我想在 theme.py 里引入 theme_product
    • 使用 from . import theme_product 就可以
    • 使用 from .theme_product import Theme_Product
      就提示 cannot import name 'Theme_Product'
      大写的 Theme_product 是 theme_product 的中的数据库类

    --------分隔线---------

    • product,theme,是多对多关系,theme_product 是中间表
    from . import theme_product
    theme=db.relationship('Theme_Product',
                                foreign_keys=[theme_product.Theme_Product.product_id],
                                backref=db.backref('backProduct',lazy='joined'),
                                lazy='dynamic',
                                cascade='all,delete-orphan')
    

    foreign_keys 那里告诉我 theme_product 没有 Theme_Product,这个 attribute
    应该如何处理呢?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3368 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 11:20 · PVG 19:20 · LAX 04:20 · JFK 07:20
    ♥ Do have faith in what you're doing.