mjumbewu / django-rest-framework-csv

CSV Tools for Django REST Framework
BSD 2-Clause "Simplified" License
364 stars 89 forks source link

Document data.header #73

Open dmacnet opened 6 years ago

dmacnet commented 6 years ago

The Ordered Fields section of the documentation should mention this third method which is supported by the renderer:

        # Try to pull the header off of the data, if it's not passed in as an
        # argument.
        if not header and hasattr(data, 'header'):
            header = data.header

This can be accomplished by using a subclass of list:

class AttributeList(list):
    """A list which can have attributes added."""

alist = AttributeList(rows_list)
alist.header = column_names_list
return Response(alist)