django-unfold
django-unfold copied to clipboard
filter on Charfield with choices
I have a 'status' field as a CharField with three choices. I added it to the list_filter in the admin, but clicking on each link shows no results because the query parameter is being generated wrong.
# models.py
NEW = _("NEW")
PENDING = _("PENDING")
PAID = _("PAID")
STATUS_CHOICES = [
(NEW, NEW.title()),
(PENDING, PENDING.title()),
(PAID, PAID.title()),
]
status = models.CharField(
_("Status"),
max_length=7,
choices=STATUS_CHOICES,
)
# admin.py
list_filter = (
"status",
)
Query params when clicking on the Pending link from the filter.
/?status__exact=P&status__exact=E&status__exact=N&status__exact=D&status__exact=I&status__exact=N&status__exact=G
This issue doesnt occur when used TextChoice class, instead of list of tuples for choices.