11 lines
339 B
Python
11 lines
339 B
Python
from django.core.serializers.json import DjangoJSONEncoder
|
|
from django.utils.encoding import force_str
|
|
from django.utils.functional import Promise
|
|
|
|
|
|
class LazyEncoder(DjangoJSONEncoder):
|
|
def default(self, obj):
|
|
if isinstance(obj, Promise):
|
|
return force_str(obj)
|
|
return super(LazyEncoder, self).default(obj)
|