morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
211 stars 64 forks source link

Issue in get_initial_queryset #112

Open Palaniyappan12 opened 1 year ago

Palaniyappan12 commented 1 year ago

Hi, thanks for your project. I'm working on project, where I need to implement a datatable based on a query. So I implemented this with the help of get_initial_queryset method. The issue is that the data is not rendered correctly, it just returns ???. I was able to find the reason, when we use values() it returns a Queryset that contains dictionary. Therefore it raises an issue, I could use only() but I need to group_by certain fields in that query. So is it possible to implement a datatable with the method get_initial_queryset that returns a query involving values()?

will1054 commented 2 months ago

Hi, thanks for your project. I'm working on project, where I need to implement a datatable based on a query. So I implemented this with the help of get_initial_queryset method. The issue is that the data is not rendered correctly, it just returns ???. I was able to find the reason, when we use values() it returns a Queryset that contains dictionary. Therefore it raises an issue, I could use only() but I need to group_by certain fields in that query. So is it possible to implement a datatable with the method get_initial_queryset that returns a query involving values()?

Did you ever figure out a way to make it work with the use of values() ?

Palaniyappan12 commented 2 months ago

I just modified the get_table_row_id function by implementing if-else conditions to manage dictionary objects. I also encountered problems with sorting and filtering, but I addressed these using a similar approach of conditional statements.