Questions

DataError at /questions/create-new-question/ value too long for type character varying(50)

0

Internal Server Error: /questions/create-new-question/

DataError at /questions/create-new-question/ value too long for type character varying(50)

data error



asked 1 year, 11 months ago
Reputation: 1





1 Answer

0

The error is coming because in some field in the model, the model the max_length is set as 50 and then we are trying to enter more than 50 characters into it.

It’s not necessary that you have explicitly set the field’s max_length as 50. In many cases it may be the default value or in some cases set by django.

In my case, here I had

slug = models.SlugField(unique=True)

and by default django sets the max_length in SlugField as 50 characters. Hence I was getting the error.

We simply need to set the max-length value greater than 50 to accomodate what we need.

Just do

slug = models.SlugField(max_length=500,unique=True)

It should work fine once you do makemigrations and migrate.

Thanks

answered 1 year, 11 months ago
Reputation: 1





Your Answer

Nothing to preview

Post Answer



Asked:  1 year, 11 months ago
Viewed:  689 times
Active:  1 year, 11 months ago