将CharField更改为TextField

时间:2016-10-14 10:12:22

标签: django django-models

我想将我的字段类型之一从CharField转换为TextField

我改变如下:

From:
project = models.CharField('Project',max_length=500)        

To:
project = models.TextField('Project',blank=True)

运行migrate cmd后,我遇到了以下错误:

django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'project' used in key specification without a key length")

我执行了上面提到的步骤 Django: Convert CharField to TextField with data intact

MySQL:
BEGIN;
    ALTER TABLE TestLog
        MODIFY failed_reqs TEXT NULL,
        MODIFY passed_reqs TEXT NULL;
COMMIT;

Bug遇到了同样的错误:

mysql> ALTER TABLE ct_task
    -> MODIFY project TEXT NULL;
ERROR 1170 (42000): BLOB/TEXT column 'project' used in key specification without a key length

任何人都可以帮助我如何进行此转换?非常感谢

0 个答案:

没有答案