0

How to solve this issue:

raise errorclass(errno, errval) django.db.utils.InternalError: (1118, u'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')

can please help to solve this problem, here is the model code:

from django.db import models

class Newsdeatils(models.Model):
    news_provider_id = models.CharField(max_length=5000)
    news_title =  models.CharField(max_length=5000)
    news_details = models.CharField(max_length=5000)
    news_image = models.CharField(max_length=5000)
    news_page_url = models.CharField(max_length=5000)
    next_page = models.CharField(max_length=5000)
    news_des = models.CharField(max_length=5000)
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104

1 Answers1

1

Just use TextField for such length requirements.

Usually, TextFields are not really limited to a specific length w.r.t. to implementation limits (regarding filesystems or the general database system used). TextFields behave very similar to CharFieldsin usage. You can read about the differences here.

Your code would change to something like that:

from django.db import models

class Newsdeatils(models.Model):
    news_provider_id = models.TextField(max_length=5000)
    news_title =  models.TextField(max_length=5000)
    news_details = models.TextField(max_length=5000)
    news_image = models.TextField(max_length=5000)
    news_page_url = models.TextField(max_length=5000)
    next_page = models.TextField(max_length=5000)
    news_des = models.TextField(max_length=5000)

Please note that setting the max_length attribute on TextFieldis not required (it is when using CharField). this max_length attribute is also not enforced on the db-level but only used for form validation.

Other things to consider in your model: Why is the news_provider_id a CharField? should that not be a ForeignKey? Same goes for things like the news_image field. This should probably be a BinaryField.

Hafnernuss
  • 2,659
  • 2
  • 29
  • 41
  • when i apply the, news_provider_id = models.TextFiled(max_length = 5000),AttributeError: 'module' object has no attribute 'TextFiled'.the issue is formed – shanto thomas Nov 20 '19 at 11:03
  • Because it is spelled 'TextField' and not 'TextFiled'. You probably also have a typo in your model name, it should probably be 'Newsdetail' and not 'Newsdeatils'. Also, if this resolved your problem please consider accepting this answer. – Hafnernuss Nov 20 '19 at 11:06
  • then also same issue is formed, File "/home/prvak/Documents/duklr/venv/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval) django.db.utils.InternalError: (1118, u'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs') here i install pip install pymysql, Can you please help me to solve this issue – shanto thomas Nov 20 '19 at 11:11
  • I'm not sure if this is related to the model you have posted. If you changed all CharFields to TextFields, this should not occure. Are there, by any chance other models that use CharFields with such high max_length attributes? Also, when does this error occur? Did you run manager.py makemigrations && migrate after changing to the TextFields? – Hafnernuss Nov 20 '19 at 11:13