我在 Django 中定义了一个模型,它(部分)看起来像这样:
class Info(models.Model):
information = models.TextField(max_length = 32, null = True, db_index = True)
然而,当我尝试syncdb
使用 MySql 后端,我得到Failed to install index for app.Info model: (1170, "BLOB/TEXT column 'information' used in key specification without a key length")
我怎样才能解决这个问题?
答案是将字段指定为CharField
, not a TextField
.
class Info(models.Model):
information = models.CharField(max_length = 32, null = True, db_index = True)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)