This can be resolved using max_length attribute. If it doesn't work try 
deleting the migration files and doing makemigrations and migrate again.

On Monday, 24 February 2020 20:14:25 UTC+5:30, Amitesh Sahay wrote:
>
> 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 
> <https://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length/1827099#1827099>
>
> MySQL error: key specification without a key length
>
> I have a table with a primary key that is a varchar(255). Some cases have 
> arisen where 255 characters isn't enou...
>
> <https://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length/1827099#1827099>
>
> *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*
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/277413b1-79a0-4e87-a181-f7dba4b23489%40googlegroups.com.

Reply via email to