django-rest-framework-datatables icon indicating copy to clipboard operation
django-rest-framework-datatables copied to clipboard

DatabaseError when using search

Open codenicks opened this issue 3 years ago • 1 comments

Hi, this is a good plugin for showing and filtering data. I have a problem though using the search field. Could you help me please ? Thankyou! DatabaseError at /app/data/ Sub SQL: None FAILED SQL: SELECT COUNT(*) FROM (SELECT DISTINCT "app_person"."id" AS Col1, "app_person"."Name" AS Col2, "app_person"."Surname" AS Col3, "app_person"."BirthDate" AS Col4, "app_person"."Sex" AS Col5 FROM "app_person" WHERE ("app_person"."Name" iLIKE %(0)s OR "app_person"."Surname" iLIKE %(1)s)) subquery Params: ('%A%', '%A%')

I have the following code:

class PersonViewSet(viewsets.ModelViewSet): queryset = Person.objects.all() serializer_class = PersonSerializer

$(document).ready(function() { $('#model').DataTable({ 'serverSide': true, 'stateSave': true, //restore table state on page reload, 'searching': true, 'ajax': '/app/data/?format=datatables', 'columns': [ {'data': 'Name', 'name': 'Name'}, {'data': 'Surname', 'name': 'Surname'}, {'data': 'BirthDate', 'searchable': false}, ] }); });`

I don't know how to put indentation, sorry.

codenicks avatar Jan 13 '22 12:01 codenicks

It seems that it's working if I comment the line 'serverSide': true

codenicks avatar Jan 13 '22 15:01 codenicks