Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

裁剪图片为什么只是显示一小部分 #16

Open
yudukanghe opened this issue May 27, 2019 · 2 comments
Open

裁剪图片为什么只是显示一小部分 #16

yudukanghe opened this issue May 27, 2019 · 2 comments

Comments

@yudukanghe
Copy link

$('#btnCrop').on('click', function(){
//alert("图片上传喽");
$.ajax({
url: '{% url "account:my_image" %}',
type: 'POST',
data: {"img": img},
success: function(e){
location.href= "{% url 'account:my_information' %}" },

            });
});

photo=models.ImageField(max_length=15000,blank=True)
个人信息页面显示的图片只是剪裁图片页面所剪裁图片的的一小部分

@yudukanghe
Copy link
Author

1、一开始没设置max_length=......,报错:Data truncated for column 'photo' at row 1") result = self._query(query),
2、猜想和varchar长度有关,开始设置max_length=255,仍然错误
3、猜想是mysql8编码问题,开始配置mysqld.cnf,仍然报错
4、看到上一楼主帖子设置了max_length=10000,遂设置max_length=150000,没报错但图片没显示完全...
5、估算了已经显示的头像部分和未显示的部分比例,遂设置max_length=300000,数据迁移的时候报错了,后来发现了varchar最大是65355
6、面对终端扑面而来的异常,是夜已经快凌晨了,心绪愈加急躁,开始删库,重新迁移数据,到处搜索
7、最后发现,无论如何,migrate的时候,总会有一个warning:....python3.6/site-packages/pymysql/cursors.py:170 (1246,"convertiong column 'photo' from VARCHAR to TEXT") result=self._query(query),重复数据迁移大约半个小时,仍然是这个东西
8、找了半天资料,都没用,最后觉得似乎可以接受这个warning,但是无关紧要为啥要warning呢
9、是夜不知几点了,只能洗澡睡觉了
10、今天本来不打算处理这个问题的,但是午饭后,想想在window环境下看看怎么样?结果还是一样,不过不删库了,知道和那没关系应该,索性再改max_length=60000,在迁移,出乎意料,图片能完全显示了!成功了!
——不知道为啥要设置这么长,然后还有那些让人觉得烦人的warning

@qiwsir
Copy link
Owner

qiwsir commented May 30, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants