[英]django.db model not found 'ForeignKey'
class Customer(models.Model):
user = models.ForeignKey(User,on_delete=models.CASCADE)
name = models.CharField(max_length=200)
locality= models.CharField(max_length=200)
city = models.CharField(max_length=50)
zipcode = models.IntegerField()
state = models.CharField(choices=STATE_CHOICES, max_length=50)
This is a part of my code.这是我的代码的一部分。
I have correctly imported models but unable to find the error.我已正确导入模型,但无法找到错误。
Error message:错误信息:
AttributeError: module 'django.db.models' has no attribute 'Foreignkey'
The code you posted is fine.你贴的代码没问题。
But You are using Foreignkey and not ForeignKey (see the uppercase K ) somewhere in your code.但是您在代码中的某处使用 Foreignkey 而不是ForeignKey (请参阅大写字母K )。
Please check for the typo in your code and fix it.请检查代码中的拼写错误并修复它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.