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

NumericRangeFilter clears all other filters #110

Closed dibusan closed 9 months ago

dibusan commented 10 months ago

Django: 3.2.22 django-admin-rangefilter: 0.9.0

# Note that both NumericRangeFilter and DateRangeFilter show the same behavior.
class MyAdminPage():
  list_filters = (
    "CustomMultiIdSearchFilter",
    "CustomTaxIdFilter",
    ("amount", NumericRangeFilter),
    ("end", DateRangeFilter),
  )
INSTALLED_APPS = [
  ...
  "django_filters",
  "rangefilter",
  "csp",
  ...
]
silentsokolov commented 10 months ago

Could you give more information? Perhaps the full step-by-step scenario?

I checked base cases and the query string generated correctly

dibusan commented 10 months ago
  1. Search on a simple string filter. GOOD
Screenshot 2023-11-27 at 12 59 02 PM
  1. Search on a range filter. BAD. The search filter clears up. Same thing happens with any other filter, including if the only 2 filters are both range filters (only 1 range filter will apply)
Screenshot 2023-11-27 at 1 02 26 PM
  1. Search on a simple string filter with the range filter applied. GOOD, both filters apply
Screenshot 2023-11-27 at 1 04 25 PM

CSP error that I cannot track. It only shows briefly when I click the range filter search and then disappears once the filer is applied (page reloads). I can say confidently this CSP error is not coming from any of our templates. Perhaps the solution in a specific CSP config ?

Screenshot 2023-11-27 at 1 14 47 PM

@silentsokolov

dibusan commented 10 months ago

I had seen this in the README but didn't understand it before. Where exactly should this setting be configured ? I add it to settings.py at the first level but has no effect.

Better view of this issue and pinpointing the template that has the CSP error:

I have set ADMIN_RANGEFILTER_NONCE_ENABLED = True in settings.py with no effect

silentsokolov commented 10 months ago
  1. I knew it all along. django-admin-rangefilter supports only default admin UI.
  2. For CSP need setup middleware / context_processors, please read docs
dibusan commented 10 months ago

@silentsokolov Even with CSP working (that means ADMIN_RANGEFILTER_NONCE_ENABLED = True in settings.py), the NumericRangeFilter does not load CSP in v 0.9.0:

Screenshot 2023-11-30 at 12 06 31 PM Screenshot 2023-11-30 at 12 09 25 PM Screenshot 2023-11-30 at 12 14 54 PM

silentsokolov commented 10 months ago

Thx, fix