Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nullable ListFields with django-rest-framework #78

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion drf_excel/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def __init__(self, list_sep, **kwargs):
super().__init__(**kwargs)

def prep_value(self) -> Any:
if len(self.value) > 0 and isinstance(self.value[0], Iterable) and not isinstance(self.value[0], str):
if self.value is None:
return super().prep_value()
elif len(self.value) > 0 and isinstance(self.value[0], Iterable) and not isinstance(self.value[0], str):
# array of array; write as json
return json.dumps(self.value, ensure_ascii=False)
else:
Expand Down