silentsokolov / django-admin-rangefilter

A Django app that lets you filter data by date range and numeric range in the admin UI
MIT License
713 stars 106 forks source link

Multiple range filters with non-unicode names don't work #18

Closed Abashinos closed 5 years ago

Abashinos commented 6 years ago

Call to django slugify function here converts any non-unicode characters (e.g. cyrillic) to empty characters, which leads to all _systemname fields being empty. In this case, any date range filters except the first one don't work at all.

Suggested solution: add transliterate package to requirements and instead of from django.template.defaultfilters import slugify use from transliterate.utils import slugify. That fixes the issue (cyrillic characters get transliterated correctly) and has no side effects as far as I see.

ghost commented 5 years ago

The provided fix introduces a new problem when thousand separator is used and set to space, because the id() function returns an integer, which gets outputted in template with spaces:

<input id="140 508 952 282 416-query-string" value="?" type="hidden">

This in turn breaks selectors in JS code and leads to a series of weird redirects instead of filtering:

[14/May/2019 08:59:45] "GET /admin/orders/order/undefined&/ HTTP/1.1" 302 0
[14/May/2019 08:59:45] "GET /admin/orders/order/undefined&/change/ HTTP/1.1" 302 0
[14/May/2019 08:59:45] "GET /admin/ HTTP/1.1" 200 25911
silentsokolov commented 5 years ago

Thx, fix