mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
More tolerant i18n deserializing
This commit is contained in:
@@ -15,13 +15,20 @@ class I18nField(Field):
|
|||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
if value is None or value.data is None:
|
if hasattr(value, 'data'):
|
||||||
|
if isinstance(value.data, dict):
|
||||||
|
return value.data
|
||||||
|
elif value.data is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
settings.LANGUAGE_CODE: str(value.data)
|
||||||
|
}
|
||||||
|
elif value is None:
|
||||||
return None
|
return None
|
||||||
if isinstance(value.data, dict):
|
|
||||||
return value.data
|
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
settings.LANGUAGE_CODE: str(value.data)
|
settings.LANGUAGE_CODE: str(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
|
|||||||
Reference in New Issue
Block a user