Commit 0043f30c by Ian Foote

Use bytes BOUNDARY on django < 1.5

Django's encode_multipart was updated in django 1.5 to work internally
with unicode and convert to bytes.

In django >= 1.5 we therefore need to pass the BOUNDARY as unicode. In
django < 1.5 we still need to pass it as bytes.
parent 78e4468f
...@@ -10,6 +10,7 @@ from __future__ import unicode_literals ...@@ -10,6 +10,7 @@ from __future__ import unicode_literals
import copy import copy
import json import json
import django
from django import forms from django import forms
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.http.multipartparser import parse_header from django.http.multipartparser import parse_header
...@@ -597,7 +598,7 @@ class MultiPartRenderer(BaseRenderer): ...@@ -597,7 +598,7 @@ class MultiPartRenderer(BaseRenderer):
media_type = 'multipart/form-data; boundary=BoUnDaRyStRiNg' media_type = 'multipart/form-data; boundary=BoUnDaRyStRiNg'
format = 'multipart' format = 'multipart'
charset = 'utf-8' charset = 'utf-8'
BOUNDARY = 'BoUnDaRyStRiNg' BOUNDARY = 'BoUnDaRyStRiNg' if django.VERSION >= (1, 5) else b'BoUnDaRyStRiNg'
def render(self, data, accepted_media_type=None, renderer_context=None): def render(self, data, accepted_media_type=None, renderer_context=None):
return encode_multipart(self.BOUNDARY, data) return encode_multipart(self.BOUNDARY, data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment