I connected django with a mysql database, I inspected db and I saved the result into models.py
then from anaconda prompt I run
python manage.py migrate
But I get some errors. One of these is
django.db.utils.ProgrammingError: BLOB/TEXT column 'Thing' used in key specification without a key length
I checked my models but I don't have any "Thing" object, just "Thing", that is a table and an attribute that I have defined in this way:
class Things(models.Model):
id_things = models.FloatField(db_column='ID_Things', blank=True, null=True) # Field name made lowercase.
things = models.CharField(db_column='Things', blank=True, null=True, max_length=256) # Field name made lowercase.
id_db = models.FloatField(db_column='ID_db', primary_key=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'things'
So I have read this thread MySQL error: key specification without a key length
hwere it says that the error pops up when we have an attibute defined as textfield or blobfield made as primary key, but in my model, "thing" is not primary key... What's the problem?
Just solved this. I had previously saved objects with an attribute called "Thing" into the database. So I deleted those contents and Django does not show the
django.db.utils.ProgrammingError: BLOB/TEXT column 'Thing' used in key specification without a key length
anymore.