Customising initial queryset

Issue #57 new
Grizzle created an issue

I am trying to filter my initial queryset to show distinct values but I can't seem to get this working in datatables.

For example in sql I would do something like this ...

select distinct column_a, column_b, column_c from database;

I can achieve this with the Django ORM by doing the following.

ModelName.objects.values('column_a', 'column_b', 'column_c').distinct().

But when I try this in the method below I get an empty json response.
    def get_initial_queryset(self):
        return self.model.objects.values('column_a', 'column_b', 'column_c').distinct()

Is there something else I should be doing to achieve this?

Comments (1)

  1. Maciej Wisniowski repo owner

    This should work properly. If you see no data then the problem is elsewhere. It is not possible to say what is wrong not seeing the whole code. Anyway, it doesn't seem to be a django-datatables-view issue.

  2. Log in to comment