如何解决这个问题:
引发错误类(errno,errval) django.db.utils.InternalError:(1118,u‘’Row大小太大)。使用的表类型的最大行大小(不包括BLOB)为65535。这包括存储开销,检查手册。您必须将某些列更改为文本或BLOB‘)
请帮助解决这个问题,下面是模型代码:
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)发布于 2019-11-20 10:50:48
只需对这样的长度要求使用TextField即可。
通常,TextFields并不局限于特定的长度w.r.t。实现限制(关于文件系统或所使用的一般数据库系统)。TextFields在使用上与CharFields非常相似。您可以阅读有关差异的这里。
您的代码将更改为这样的内容:
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)请注意,在max_length上设置TextField属性并不是必需的(在使用CharField时是这样)。这个max_length属性也不是在db级别上强制执行的,而是只用于表单验证。
模型中要考虑的其他问题:为什么news_provider_id是CharField?那不应该是ForeignKey吗?类似于news_image字段的情况也是如此。这可能是一个BinaryField。
https://stackoverflow.com/questions/58952339
复制相似问题