django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')

前端 未结 7 649
故里飘歌
故里飘歌 2020-12-15 09:03

My model:

class Course(models.Model):
    language = models.ForeignKey(Language)
    name = models.CharField(max_length=50, unique=True, default=\'course\')
         


        
7条回答
  •  执笔经年
    2020-12-15 09:26

    I ended up adding

    'OPTIONS': { 'init_command': 'SET storage_engine=INNODB;' }
    

    to my DB backed configuration in settings.py and that fixed the problem.

    The MySQL server was configured to use InnoDB as a default engine, but due to some reason it still tried to create tables with the MyISAM. I am running MySQL 5.1 with Django 2.2.1 and Python 3.6.7

提交回复
热议问题