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

RemovedInDjango30Warning: {% load admin_static %} is deprecated #26

Closed daniel-ruiz closed 5 years ago

daniel-ruiz commented 5 years ago

Hello! 👋

I wanted to thank you for building this package beforehand. It saved me and my teammates a whole deal of work!

We are using the latest version of django-admin-rangefilter (v0.3.10) in our Django project. Recently, after upgrading Django to version 2.1 we started seeing the following deprecation warning in our logs:

RemovedInDjango30Warning: {% load admin_static %} is deprecated in favor of {% load static %}

I've found out there are several references to admin_static in django-admin-rangefilter that are likely the source of these warnings (see here).

It would be amazing that this warning will be suppressed. Do not hesitate to contact me if you need some help with the fix 😄

silentsokolov commented 5 years ago

Hello!

Thanks for issue and PR but there is a problem: we support Django 1.8+. In version 1.8/1.9 admin_static is not deprecated.

daniel-ruiz commented 5 years ago

Hmm! I wasn't sure the change will be backwards compatible. Thanks for the hint!

I see there are 2 different templates in the package (rangefilter/date_filter_1_8.html and rangefilter/date_filter.html) and the code serves one template or the other depending on the version of Django.

Would it be enough if I just edited one of the templates (rangefilter/date_filter.html)? Or do you see this issue harder to fix with the current code?

silentsokolov commented 5 years ago

1.8.x is normal, package uses template rangefilter/date_filter_1_8.html 1.9.x is normal, package uses template rangefilter/date_filter.html 1.10.x is deprecated, package uses template rangefilter/date_filter.html

I do not want to create a template for version 1.9 :(

You can override the template rangefilter/date_filter.html in your project if this problem bothers you.

Best solution create custom template tag, which depending on the version, will call the function admin_static or static

silentsokolov commented 5 years ago

@daniel-ruiz upgrade to 0.3.11 and thanks for PR!

daniel-ruiz commented 5 years ago

@silentsokolov thank you for maintaining this awesome project! It was great to contribute and I learned a lot along the way.