<bdo id='v5GGD'></bdo><ul id='v5GGD'></ul>

  • <small id='v5GGD'></small><noframes id='v5GGD'>

    <legend id='v5GGD'><style id='v5GGD'><dir id='v5GGD'><q id='v5GGD'></q></dir></style></legend>

        <i id='v5GGD'><tr id='v5GGD'><dt id='v5GGD'><q id='v5GGD'><span id='v5GGD'><b id='v5GGD'><form id='v5GGD'><ins id='v5GGD'></ins><ul id='v5GGD'></ul><sub id='v5GGD'></sub></form><legend id='v5GGD'></legend><bdo id='v5GGD'><pre id='v5GGD'><center id='v5GGD'></center></pre></bdo></b><th id='v5GGD'></th></span></q></dt></tr></i><div id='v5GGD'><tfoot id='v5GGD'></tfoot><dl id='v5GGD'><fieldset id='v5GGD'></fieldset></dl></div>

        <tfoot id='v5GGD'></tfoot>

        django.db.utils.OperationalError: (1071, '指定的密钥太长;最大密钥长度

        django.db.utils.OperationalError: (1071, #39;Specified key was too long; max key length is 767 bytes#39;)(django.db.utils.OperationalError: (1071, 指定的密钥太长;最大密钥长度为 767 字节))

            <small id='zYfCo'></small><noframes id='zYfCo'>

            <legend id='zYfCo'><style id='zYfCo'><dir id='zYfCo'><q id='zYfCo'></q></dir></style></legend>
            <i id='zYfCo'><tr id='zYfCo'><dt id='zYfCo'><q id='zYfCo'><span id='zYfCo'><b id='zYfCo'><form id='zYfCo'><ins id='zYfCo'></ins><ul id='zYfCo'></ul><sub id='zYfCo'></sub></form><legend id='zYfCo'></legend><bdo id='zYfCo'><pre id='zYfCo'><center id='zYfCo'></center></pre></bdo></b><th id='zYfCo'></th></span></q></dt></tr></i><div id='zYfCo'><tfoot id='zYfCo'></tfoot><dl id='zYfCo'><fieldset id='zYfCo'></fieldset></dl></div>
            • <bdo id='zYfCo'></bdo><ul id='zYfCo'></ul>
                <tfoot id='zYfCo'></tfoot>
                    <tbody id='zYfCo'></tbody>
                • 本文介绍了django.db.utils.OperationalError: (1071, '指定的密钥太长;最大密钥长度为 767 字节')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的模特:

                  class Course(models.Model):
                      language = models.ForeignKey(Language)
                      name = models.CharField(max_length=50, unique=True, default='course')
                      title = models.CharField(max_length=1024, default='no title')
                      foreign_title = models.CharField(max_length=1024, default='no title', blank=True)
                      header = models.CharField(max_length=1024, default='', blank=True)
                      description = models.TextField(null=True, blank=True)
                  
                      def __str__(self):
                          return self.title
                  
                      def __unicode__(self):
                          return u'%s' % self.title
                  

                  我添加unique_together":

                  I am add "unique_together":

                  class Course(models.Model):
                      language = models.ForeignKey(Language)
                      name = models.CharField(max_length=50, unique=True, default='course')
                      title = models.CharField(max_length=1024, default='no title')
                      foreign_title = models.CharField(max_length=1024, default='no title', blank=True)
                      header = models.CharField(max_length=1024, default='', blank=True)
                      description = models.TextField(null=True, blank=True)
                  
                      class Meta:
                          unique_together = ['language', 'name', 'title']
                  
                      def __str__(self):
                          return self.title
                  
                      def __unicode__(self):
                          return u'%s' % self.title
                  

                  出现错误的迁移时间:

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

                  我的数据库是:mysql Ver 15.1 Distrib 10.0.17-MariaDB,用于 debian-linux-gnu (x86_64) 使用 readline 5.2

                  My DB is: mysql Ver 15.1 Distrib 10.0.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

                  我尝试增加mysql的索引长度:

                  I tried to increase the length of the index mysql:

                  MariaDB [(none)]> set global innodb_file_format = BARRACUDA;
                  Query OK, 0 rows affected (0.00 sec)
                  
                  MariaDB [(none)]> set global innodb_large_prefix = ON;
                  Query OK, 0 rows affected (0.00 sec)
                  

                  但这还不够:

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

                  问题索引长度.django索引如何指定长度限制?

                  The problem index length. How to specify the length limit Django index?

                  推荐答案

                  解决方案是

                  ALTER DATABASE `databasename` CHARACTER SET utf8; 
                  

                  这篇关于django.db.utils.OperationalError: (1071, '指定的密钥太长;最大密钥长度为 767 字节')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)

                    <legend id='eJh8E'><style id='eJh8E'><dir id='eJh8E'><q id='eJh8E'></q></dir></style></legend>
                      <tbody id='eJh8E'></tbody>

                      • <small id='eJh8E'></small><noframes id='eJh8E'>

                        <i id='eJh8E'><tr id='eJh8E'><dt id='eJh8E'><q id='eJh8E'><span id='eJh8E'><b id='eJh8E'><form id='eJh8E'><ins id='eJh8E'></ins><ul id='eJh8E'></ul><sub id='eJh8E'></sub></form><legend id='eJh8E'></legend><bdo id='eJh8E'><pre id='eJh8E'><center id='eJh8E'></center></pre></bdo></b><th id='eJh8E'></th></span></q></dt></tr></i><div id='eJh8E'><tfoot id='eJh8E'></tfoot><dl id='eJh8E'><fieldset id='eJh8E'></fieldset></dl></div>

                        • <bdo id='eJh8E'></bdo><ul id='eJh8E'></ul>
                        • <tfoot id='eJh8E'></tfoot>