6

我在 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")

我怎样才能解决这个问题?

4

1 回答 1

8

答案是将字段指定为 a CharField,而不是 a TextField

class Info(models.Model):
    information = models.CharField(max_length = 32, null = True, db_index = True)
于 2012-06-21T13:26:48.577 回答