# in tablize function
if data : # data is empty , this becomes false
# do something
else: # executed if data is empty
return []
hence, when data is empty, no headers returned
If you remove above if else
the code will be like this
def tablize(self, data):
data = self.flatten_data(data)
# for empty data, headers will be None
data.header = data.header or self.headers
if not data.header:
headers = set()
for item in data: # for empty data , wont enter loop this is the reason for not returning headers
headers.update(list(item.keys()))
data.header = sorted(headers)
rows = []
for item in data: # for empty data , wont enter loop
row = []
for key in data.header:
row.append(item.get(key, None))
rows.append(row)
return [data.header] + rows # empty list is returned
If you want headers to be returned, refer to #27 for more details.
hope this answers your question
@dbkaplun in renderers.py
hence, when data is empty, no headers returned If you remove above
if else
the code will be like thisIf you want headers to be returned, refer to #27 for more details. hope this answers your question