我正在用 python djnago 开发一个应用程序,我是新手所以我的问题听起来很原始我在尝试运行 syncdb 时遇到了这个错误
TypeError: Error when calling the metaclass bases
unbound method contribute_to_class() must be called with IntegerField
instance as first argument (got ModelBase instance instead)
这是 models.py 的代码片段
class Type(models.Model):
name = models.CharField(max_length=60)
description = models.CharField(max_length = 200)
class TypeModel(models.Model):
importance = models.IntegerField
name = models.CharField(max_length=70)
description = models.CharField(max_length=200)
type = models.ForeignKey(Type)
当我尝试运行以下命令时
python manage.py syncdb
我在问题的顶部得到了错误 我还不得不说,在我将 TypeModel 添加到 models.py 文件之前,它曾经完美地工作,我在哪里犯了错误,如果有人能提供帮助,我将不胜感激
请您参考如下方法:
你的 importance = models.IntegerField,好的 models.IntegerField(default=0) 或 models.IntegerField()
