django-rest-framework-csv icon indicating copy to clipboard operation
django-rest-framework-csv copied to clipboard

Add column header setting

Open liamdiprose opened this issue 6 years ago • 0 comments

This PR adds the ability to define the CSV column order from within the code Currently, the CSV Parser assumes the first row of CSV data contains the column names.

This PR adds the ability to define the column names from the ViewSet class:

class CSVEndpoint(viewsets.ModelViewSet):
    serializer_class = CSVSerializer
    parser_classes = (CSVParser,)

    csv_header = ("time", "temperature")

There are still a few small things I would like to address before this is merged. Namely

  • [ ] Is the viewset class the appropriate place to define the csv_header variable?
  • [ ] Testing? I've only manually-tested this with my own project so far.
  • [ ] Code style, this is quick and dirty; is there more django-y way of doing this?

Thanks

liamdiprose avatar May 28 '19 05:05 liamdiprose