You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the case I’m currently working on, I don’t know (and have no easy way to retrieve) all CSV headers in advance. It’d be great if this library would expose an overridable def sort_headers method.
The text was updated successfully, but these errors were encountered:
or simply choose whether to sort the headers or not. For me it seems weird that you want alphabetically ordered fields, but it's fair if some people want that - but why not make it based on the serializer as the rest of DRF does? so if you want them alphabetical order, then you simply order them alphabetically in the serializer.
It's really difficult to change the fields in the viewset currently. Currently i am doing:
def get_renderer_context(self):
context = super().get_renderer_context()
# force the order from the serializer.
context['header'] = self.serializer_class.Meta.fields
return context
But that is really hacky (and seems weird that i have to force it to do the 'default'. Also this was problematic (the code above) when i went to change fields dynamically in the serializer making the seperation of responsibilities really difficult.
TL;DR Please just remove the ordering and/or make a function where you can PICK to choose to sort them alphabetically. I can make a PR if neeeded be that fixes this, but i would prefer that it is merged if i spend time creating it.
In the case I’m currently working on, I don’t know (and have no easy way to retrieve) all CSV headers in advance. It’d be great if this library would expose an overridable
def sort_headers
method.The text was updated successfully, but these errors were encountered: