Refs #27795 -- Removed force_bytes()/smart_text() from model fields.
This commit is contained in:
parent
c122a7c53c
commit
90f3ef332b
|
@ -25,7 +25,6 @@ from django.utils.dateparse import (
|
||||||
parse_date, parse_datetime, parse_duration, parse_time,
|
parse_date, parse_datetime, parse_duration, parse_time,
|
||||||
)
|
)
|
||||||
from django.utils.duration import duration_microseconds, duration_string
|
from django.utils.duration import duration_microseconds, duration_string
|
||||||
from django.utils.encoding import force_bytes, smart_text
|
|
||||||
from django.utils.functional import Promise, cached_property
|
from django.utils.functional import Promise, cached_property
|
||||||
from django.utils.ipv6 import clean_ipv6_address
|
from django.utils.ipv6 import clean_ipv6_address
|
||||||
from django.utils.itercompat import is_iterable
|
from django.utils.itercompat import is_iterable
|
||||||
|
@ -828,7 +827,7 @@ class Field(RegisterLookupMixin):
|
||||||
else 'pk'
|
else 'pk'
|
||||||
)
|
)
|
||||||
return (blank_choice if include_blank else []) + [
|
return (blank_choice if include_blank else []) + [
|
||||||
(choice_func(x), smart_text(x))
|
(choice_func(x), str(x))
|
||||||
for x in rel_model._default_manager.complex_filter(limit_choices_to)
|
for x in rel_model._default_manager.complex_filter(limit_choices_to)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2280,12 +2279,12 @@ class BinaryField(Field):
|
||||||
|
|
||||||
def value_to_string(self, obj):
|
def value_to_string(self, obj):
|
||||||
"""Binary data is serialized as base64"""
|
"""Binary data is serialized as base64"""
|
||||||
return b64encode(force_bytes(self.value_from_object(obj))).decode('ascii')
|
return b64encode(self.value_from_object(obj)).decode('ascii')
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
# If it's a string, it should be base64-encoded data
|
# If it's a string, it should be base64-encoded data
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
return memoryview(b64decode(force_bytes(value)))
|
return memoryview(b64decode(value.encode('ascii')))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue