【发布时间】:2020-10-13 22:55:50
【问题描述】:
应用结构
areas models.py
from django.db import models
from products.models import ProductModel
class ProductionLine(models.Model):
name = models.CharField(max_length = 50, unique=True)
产品模型.py
from django.db import models
from areas.models import ProductionLine
class ProductModel(models.Model):
name= models.CharField(max_length = 255, unique=True)
productionLine = models.ForeignKey(ProductionLine,on_delete=models.CASCADE)
我正在尝试导入 ProductionLine,但是当我导入 ProductionLine 时出现错误:
- 文件“/app/areas/models.py”,第 2 行,在 *
- 从 products.models 导入 ProductModel*
- ImportError: 无法导入名称“ProductModel”*
当我在 products.models 中删除 ProductionLine 的导入时,一切正常。我不明白
【问题讨论】:
-
您是否已将产品应用添加到设置中?
标签: django django-models django-rest-framework