reg: Error:-django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description' used in key specification without a key length")

845 views
Skip to first unread message

Amitesh Sahay

unread,
Feb 24, 2020, 9:44:25 AM2/24/20
to Django Users
Hi, 

I am creating a model, which is taking a description as text field. when I migrate I see the below error:

django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description' used in key specification without a key length")

ON further research I came to know that its some limitation with MySQL. I am using MYSQL for my dev. Below is the link that describes the issue.

MySQL error: key specification without a key length


So what am I suppose to use if not TextField? I have tried CharField, that doesn't work either. Below is the model details:

class OnlineShop(models.Model):
Product_name = models.CharField(max_length=100, unique=True)
Price = models.IntegerField()
Slug = models.SlugField(max_length=250, unique=True)
Description = models.TextField()
Curr_Time = models.DateTimeField(auto_now_add=True)

def __str__(self):
return '{}'.format(self.Product_name)


Regards,
Amitesh Sahay
91-750 797 8619

Integr@te System

unread,
Feb 24, 2020, 2:54:00 PM2/24/20
to django...@googlegroups.com
Hi Freind,

For simplify and minimize your dev time, review first in your err, code base.
Thank your sharing and dont forget zen.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1073924601.858407.1582555396348%40mail.yahoo.com.

Pankaj Sharma

unread,
Feb 25, 2020, 7:29:54 AM2/25/20
to Django users
You haven't set max_len of TextField, use this - do it like this --  Description = models.TextField(max_length=1000)

Naveen Arora

unread,
Feb 25, 2020, 7:59:50 AM2/25/20
to Django users
This can be resolved using max_length attribute. If it doesn't work try deleting the migration files and doing makemigrations and migrate again.

Ganesh Babu

unread,
Feb 25, 2020, 8:57:08 AM2/25/20
to django...@googlegroups.com
Hi Team,
     I am getting an issue that issue i.e., ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

i am trying to install mysql using django template.   please help me.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1073924601.858407.1582555396348%40mail.yahoo.com.


--
Best Regards
Sri Ganesh Babu.S
Sr. Software Engineer,

Doyen Solutions


Reply all
Reply to author
Forward
0 new messages