V
V
vikholodov2018-03-19 22:09:21
Django
vikholodov, 2018-03-19 22:09:21

How to fix the value does not fit in the character varying(50) type?

Colleagues, welcome!
I bring the image files into the database using the link.
Got a very strange error: django.db.utils.DataError: ERROR: value does not fit character varying(50).

img_name1 = urlparse(image).path.split('/')[-1]
response = requests.get(image)
if response.status_code == 200:
        product.image.save(img_name1, ContentFile(response.content), save=True)

Swears on a line
product.image.save(img_name1, ContentFile(response.content), save=True)

I made a print img_name1, there are no more than 6 characters, only ContentFile (response.content) remains.
Then the question is, how to increase the limit? Unfortunately, nothing was found

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Ozerov, 2021-12-27
@alex_vma

who will google even after so many years - change the type to varchar (255) or varchar (500) for example, or if even this was not enough for you, then change to TEXT type - here the column limit is almost 1 GB

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question