将字段添加到Django模型

问题描述

我正在从事这个项目:https://github.com/mirumee/saleor

我想在产品表中添加一个“ user_id”列。 所以,我在第248行添加了以下代码 https://github.com/mirumee/saleor/blob/master/saleor/product/models.py#L248

account_user = models.ForeignKey(
    Account_User,related_name="products",on_delete=models.CASCADE,)

但是,Django说“ NameError:名称'Account_User'未定义”。我该如何解决这个问题?谢谢

解决方法

from ..account.models import User

account_user = models.ForeignKey(
User,related_name="products",on_delete=models.CASCADE)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...