数据在表单发送时损坏,= \r\\\<br/>在每75个字符的数据中引入数据? [英] Data gets corrupted on form send, =\r\n introduced in the data every 75 characters?
问题描述
我正在Google App Engine上进行Django nonrel的项目,虽然我有一种感觉,我的问题与这些直接无关。
我在一个模型中有一个隐藏的字段,定义如下:
models.CharField(max_length = 400,null = True,blank = True,default ={})
该字段旨在接收JSON数据来自我的管理员中的小部件,客户端的值会正确更改。
(正在发送的数据与我的问题无关 - 无论是字符串在该字段的值被损坏)
问题是 -
当我看到数据被传递到django保存功能,我看到每75个字符我得到数据字符串内的 = \r\\\
。这有效地打破了字符串,使我的数据无用。我不知道这是从哪里来的,或者是什么原因。
更有趣的点:
- 由于我使用GAE blobstore上传该表单中的文件,所以管理表单有
enctype ='multipart / form-data'
- 我正在使用 django-filetransfers 以方便使用blobstore
- 我已经检查了浏览器中出现的请求,出来的数据很干净
- Django将模型中的数据保存为UTF8
我没有发现任何远程接近我的问题在谷歌...
有没有人有解决方案?或者可能是从哪里开始寻找的方向?
原来,问题是 Google App Engine中的此错误
我在这里找到我的解决方案:提交多部分/表单数据表单时,应用引擎中的编码问题
使用Andres Bossard中间件修复该问题已解决问题
I'm working on a project in Django nonrel, on Google App Engine, though I have a feeling my problem has nothing to do with either of these directly .
I have a hidden field in one of the models that is defined like so:
models.CharField(max_length=400, null=True, blank=True,default="{}")
The field is meant to receive JSON data from a widget in my admin, and in the client its value changes properly.
(Which data is being sent is irrelevant to my problem - whatever string is in the field value is being corrupted)
The problem is -
when I look at the data as passed to the django save function , I see that every 75 characters I get =\r\n
inside the data string. This effectively breaks the string, rendering my data useless. I have no idea where this is coming from, or what causes this.
More interesting points:
- The admin form has
enctype='multipart/form-data'
, since I use GAE blobstore to upload a file in that form - I'm using django-filetransfers to facilitate working with the blobstore
- I've checked the request going out of the browser, the data going out is clean
- Django saves the data in the model as UTF8
I haven't found anything remotely close to my problem on google...
Does anyone have a solution? Or maybe a direction on where to start looking?
So it turns out the problem is a result of this bug in Google App Engine
I found my solution here: Encoding problem in app engine when submitting multipart/form-data forms
The problem was solved using Andres Bossard middleware fix in that thread
这篇关于数据在表单发送时损坏,= \r\\\<br/>在每75个字符的数据中引入数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!