我使用DJango 1.6和python 2.7创建了一个类模型,如下所示:
class Company(models.Model):
Name = models.CharField(max_length=150)
PhoneNumber = models.CharField(max_length=20)
Email = models.EmailField
CompanyLogo = models.BinaryField
尝试使用python manage.py sql fetch
创建代表sql导致错误:
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/db/models/base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
TypeError: Error when calling the metaclass bases
unbound method contribute_to_class() must be called with BinaryField instance as first argument (got ModelBase instance instead)
postgresql数据库中的相应字段是bytea
类型答案 0 :(得分:1)
EmailField
和BinaryField
都缺少()
更改要编写的类,这样就解决了问题
class Company(models.Model):
Name = models.CharField(max_length=150)
PhoneNumber = models.CharField(max_length=20)
Email = models.EmailField()
CompanyLogo = models.BinaryField()