Sunday, August 14, 2022

django, datatables and sorting on custom calculated values

I'm having some issues with django (3.2) and the django-datables-view app.

Working with a single model I can get a nice javascript datatables view with pagination, sorting, filtering all server side etc. However, as soon as I calculate custom columns, based on an intricate query involving 3 other tables in the django database, I cannot get sorting and filtering to work. (it does display correctly though, so the query code is working). I tried to leave the server side part and let datatables do the sorting and filtering 'in browser' but it becomes slow with >500records

Any suggestions? Would https://django-rest-framework-datatables.readthedocs.io/en/latest/
be an option? Or does that also first calculates the whole json necessary for datatabels instead of server side pagination/filtering/sorting of the results?

I'm querying one model now and insert the custom columns in the view as in the django-datatables-view docs, but maybe I should prepare the whole query with the custom columns as annotations in the queryset. i'm not sure if you can sort on those though.

Who has some experience with this and willing to share some code (as the examples do not seem to include custom column  filtering/sorting) or other suggestions?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a8f12e49-9ba3-41e6-b90e-9b634db16ce9n%40googlegroups.com.

No comments:

Post a Comment