Logging: Automatically serialize file objects

Sentry PRETIXEU-RY
This commit is contained in:
Raphael Michel
2019-01-30 10:59:00 +01:00
parent acdf7d62b5
commit 87424c25de

View File

@@ -1,3 +1,4 @@
from django.core.files import File
from i18nfield.utils import I18nJSONEncoder
from pretix.base.reldate import RelativeDateWrapper
@@ -7,6 +8,8 @@ class CustomJSONEncoder(I18nJSONEncoder):
def default(self, obj):
if isinstance(obj, RelativeDateWrapper):
return obj.to_string()
elif isinstance(obj, File):
return obj.name
else:
return super().default(obj)