Please dont mark it as dupliacte .I have been searching for three days on community I am using alibaba cloud services for hosting and I got this error django.db.utils.operationalerror: (1071, 'specified key was too long; max key length is 767 bytes') when i run python3 manage.py migrate my problem is similar as mentioned here Django deploying on MySQL gives #1071 error "Specified key was too long" my model.py file is `
from django.db import models
class SendRequest(models.Model):
rid=models.AutoField(primary_key=True)
uname=models.CharField(max_length=256)
problemcode=models.CharField(max_length=256)
languageused=models.CharField(max_length=50)
question=models.TextField()
description=models.TextField()
codesnapshot=models.TextField()
status=models.BooleanField(default=False)
date = models.DateTimeField(default=datetime.now,null=False)
class ReceiveRequest(models.Model):
rrid=models.ForeignKey(SendRequest,on_delete=models.CASCADE)
uname=models.CharField(max_length=256)
class Meta:`enter code here`
unique_together = (("rrid", "uname"),)`
When i use SendRequest Model i didnt get any error but when i add ReceiveRequest table i got the above error **my settings.py is **
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME' : 'dbdiv',
'USER' : '********',
'PASSWORD':'********',
'HOST' : 'rm-6gjg9lt559w00uv6yeo.mysql.ap-south-1.rds.aliyuncs.com',
'PORT' : '3306',
'OPTIONS': {
'init_command':'SET character_set_connection=utf8,collation_connection=utf8_unicode_ci',
},
}
}
I tried all possible ways by dropping and adding database again and i created database with CREATE DATABASE dbdiv CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Please help me .
my problem is similar to Django deploying on MySQL gives #1071 error "Specified key was too long"
mention answer