Skip to content

Commit

Permalink
Add labeled headers to csvs with no data (#58)
Browse files Browse the repository at this point in the history
CSVs with no data should still use header labels
This change mirrors label behavior that occurs when there is data
  • Loading branch information
travisbloom authored and mjumbewu committed Jan 11, 2017
1 parent 4042395 commit 2ff49cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rest_framework_csv/renderers.py
Expand Up @@ -104,7 +104,10 @@ def tablize(self, data, header=None, labels=None):

elif header:
# If there's no data but a header was supplied, yield the header.
yield header
if labels:
yield [labels.get(x, x) for x in header]
else:
yield header

else:
# Generator will yield nothing if there's no data and no header
Expand Down

0 comments on commit 2ff49cf

Please sign in to comment.