I am having the same issue as the user from this post, however, all of the proposed solutions did not work for me. I am using MySQL 8.0.24 with Django 3.1.
Similar to them, I had a model without a unique_together
field as shown below
class Show(models.Model):
english_name = models.CharField(max_length=400)
kanji_name = models.CharField(max_length=200, blank=True)
romanji_name = models.CharField(max_length=400, blank=True)
show_type = models.CharField(max_length=100, blank=True)
# a bunch of other fields...
class Meta:
verbose_name_plural = 'Series'
ordering = ('-created',)
unique_together = ['english_name', 'kanji_name', 'romanji_name', 'show_type']
def __str__(self):
return self.english_name
It was only until I changed class Meta
to this
class Meta:
verbose_name_plural = 'Series'
ordering = ('-created',)
unique_together = ['english_name', 'kanji_name', 'romanji_name', 'show_type']
That I started receiving this error whenever I migrated my database.
django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 3072 bytes')
I followed the steps in the post I linked above to ensure the utf8 was used, I was able to confirm that the dataset was using that character set, but it didn't resolve my issue. Is there anything else I can do to ensure that the unique_together
field can be used?