Python Django迁移,找不到'User'字段
当我尝试跑步时:Python Django迁移,找不到'User'字段,python,django,migration,Python,Django,Migration,当我尝试跑步时: python../manage.py makemigrations Myapp 它说: class Tld(models.Model): #TODO...resolve `User` table issue for FKtoClient #other fields FKtoClient = models.ForeignKey('User', on_delete=models.PROTECT) 我如何解决这个问题 谢谢。您没有从django.contrib.
python../manage.py makemigrations Myapp
它说:
class Tld(models.Model): #TODO...resolve `User` table issue for FKtoClient
#other fields
FKtoClient = models.ForeignKey('User', on_delete=models.PROTECT)
我如何解决这个问题
谢谢。您没有从
django.contrib.auth.models
导入用户
,所以从django.contrib.auth.models导入用户
?这包含在我的文件的第1行。删除引号,django会将其视为字符串,表示此模型在当前应用程序中,而不是,将应用程序作为字符串的一部分引用:'auth.User'
,则不需要导入它。
Myapp.Tld.FKtoClient: (fields.E300) Field defines a relation with model 'User', which is either not installed, or is abstract.
Myapp.Tld.FKtoClient: (fields.E307) The field Myapp.Tld.FKtoClient was declared with a lazy reference to 'Myapp.user', but app 'Myapp' doesn't provide model 'user'.