0👍
Not exactly this error no but, I was having a very similar error:
django.db.utils.OperationalError: (1025, 'Error on rename of ... (errno: 150 Foreign key constraint is incorrectly formed
Dropping foreign key didn’t solve my problem. However, I figured out that is a charset
error. So, if you have this error probably you are trying to create new table with a different charset
. So, setting default charset collation across the database solved my issue. In my case, I had error on django unit test db so;
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': env('DB_NAME'),
'USER': env('DB_USERNAME'),
'PASSWORD': env('DB_PASSWORD'),
'HOST': env('DB_HOST'),
'PORT': '',
'TEST': {
'CHARSET': 'latin1',
'COLLATION': 'latin1_swedish_ci',
}
},
}
this configuration worked.
- Can't add extra argument to Python(Django) function call
- Django: do SQL join for getting row count
- Django Admin cannot render tables without Primary Key
Source:stackexchange.com