Data gets corrupted on form send, =\r\n introduced

2019-07-04 08:56发布

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?

1条回答
我只想做你的唯一
2楼-- · 2019-07-04 09:25

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

查看更多
登录 后发表回答