Skip to content

Commit

Permalink
fix if custom_cols is None
Browse files Browse the repository at this point in the history
fixes bug introduced in #40
  • Loading branch information
willtho89 committed Nov 9, 2021
1 parent cce21fb commit 82af43b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions drf_renderer_xlsx/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ def render(self, data, accepted_media_type=None, renderer_context=None):
self.xlsx_header_dict = self._flatten_serializer_keys(
drf_view.get_serializer(), use_labels=use_labels
)

custom_header_dict = {
key: self.custom_cols[key].get('label', None) or key
for key in self.custom_cols.keys()
}
self.combined_header_dict = dict(
list(self.xlsx_header_dict.items()) + list(custom_header_dict.items())
)
if self.custom_cols:
custom_header_dict = {
key: self.custom_cols[key].get('label', None) or key
for key in self.custom_cols.keys()
}
self.combined_header_dict = dict(
list(self.xlsx_header_dict.items()) + list(custom_header_dict.items())
)
else:
self.combined_header_dict = self.xlsx_header_dict

for column_name, column_label in self.combined_header_dict.items():
if column_name == "row_color":
Expand Down

0 comments on commit 82af43b

Please sign in to comment.