Adding DT_RowId into the datatables source
Hi Maciej, thanks for the library.
Something that's not mentioned in the docs is the act of adding a 'DT_RowId' column into the data. As the data from the view comes back an arrary rather than a dictionary, I've not been able to follow the Datatables tutorials which expect it as a named field in the object [1].
Have you any experience of solving this problem? I'd be happy to help update the docs if it's worked out.
Thanks. Phil
[1] e.g. https://datatables.net/examples/server_side/ids.html
Comments (4)
-
repo owner -
repo owner - marked as trivial
-
reporter Thanks Maciej, that's great and thanks for quick reply. I'm relatively new to Django (from Flask) and am regularly suprised by how extensive and customisable Django is. Formatting the queryset objects before returning them makes total sense.
-
reporter - changed status to resolved
Resolved as-per Maciej's recommendation.
- Log in to comment
If you want to customize/have full control over returned data you can just override prepare_results method of base class. Have a look at the end of the https://bitbucket.org/pigletto/django-datatables-view/src for a sample customisation. In your case you'd want to return dictionary instead of list.