Skip to content
Advertisement

How to create a filter a column in a data table in Django?

I have a data table in my Django project. This data table is for listing customers. The customer has attributes like name, country, email, etc… I want to put a button like a dropdown menu for listing countries of customers. (Excel-like or similar logic) But I just need this in the country column. How can I do that?

I try to use django-filters but didn’t work.

customer_list.html

JavaScript

views.py

JavaScript

filters.py

JavaScript

Advertisement

Answer

It’s apparent that the code that you have posted is only part of the code and so it’s not possible to see all the issues that may prevent it from working, part of the problem is that the fields parameter in your filters.py should have square brackets and no comma. It should read:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement