django-datatable
django-datatable copied to clipboard
Multiple search field
For example, I have this:
<th data-data="customer" data-name="customer.first_name">Customer</th>
I want to search it from field customer.first_name also customer.last_name, how I can combinate it all? egg look like this (or by another option):
<th data-data="customer" data-name="customer.first_name;customer.last_name">Customer</th>
Hi! I was having the same issue. I came to see if someone solved it and saw your comment. I finally solved it using and annotate in the queryset to add the full_name field.
queryset.annotate(
full_name=Concat(
F("customer__first_name"),
Value(" "),
F("customer__last_name"),
output_field=CharField(),
)
)
Then in the column definition of the table, the field would be full_name and just let header as Customer. The search will now work with both first_name and last_name.
I guess I come a bit late for you, but I hope this can be useful for someone.