Django issue during migrations - lazy reference
我当前已将此模型添加到我的应用程序中
1 2 3 4 5 6 | from mainApp.models import modelPatient class modelBodyParts(models.Model): part_name = models.CharField(max_length=1000, unique=False , default="") modelPatient = models.ForeignKey(modelPatient) result = models.CharField(max_length=3000, unique=False , default="") |
现在makemigrations和migrate命令给出了以下错误
1 2 3 4 | >>python manage.py makemigrations >>python ./manage.py migrate ValueError: The field interviewApp.modelInterviewAnswers.patients was declared with a lazy reference to 'mainApp.modelpatients', but app 'mainApp' doesn't provide model 'modelpatients' |
号
我不知道那是什么意思。但我记得有一次,
尝试使用
对我来说,发生了这个错误,因为我从
1 | my_field = models.ForeignKey('old.model', ...) |
到
1 | my_field = models.ForeignKey('new.model', ...) |
号
解决方案是手动编辑生成的迁移,并添加来自
1 2 3 4 5 | class Migration(migrations.Migration): dependencies = [ ('old', '0016_whatever'), ('new', '0002_latest_migration'), # Add this line ] |