【发布时间】:2019-07-12 10:09:07
【问题描述】:
我的 Django 项目中有这个模型:
class Institution(models.Model):
name = models.CharField(unique=True, max_length=100, blank=True)
description = models.TextField(max_length=500, null=True, blank=True)
def __str__(self):
return self.name
当我使用 SQLite 时,我完全运行了我的项目,但是当我将我的数据库引擎更改为 Mysql 时,我收到了这个错误:
MySQLdb._exceptions.OperationalError: (1170, "BLOB/TEXT column 'name' used in key specification without a key length")
我必须做什么?
【问题讨论】:
-
我的
name字段中有unique=True,,当我删除它时,错误消失了,但我不知道原因! -
解释见这里 :-): stackoverflow.com/questions/1827063/…
标签: python django django-models django-2.2 django-mysql