Git Product home page Git Product logo

django-admin-numeric-filter's People

Contributors

cunla avatar jackatomenapps avatar jacqueswww avatar jurrian avatar lukasvinclav avatar makegodhere avatar petrkudy avatar qdelcourte avatar qu4tro avatar tovmeod avatar tuky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-admin-numeric-filter's Issues

The text of the filter doesn't translate

I use LANGUAGE_CODE setup in Django settings (USE_I18N and USE_L10N are also = True) and I want my admin panel to be translated into Russian language. Everything except the filters from this lib has been translated.
image

Add pyproject.toml to remove warning when installing with pip

This is related to pypa/pip#8559

Currently we get the following warning when installing with pip

DEPRECATION: django-admin-numeric-filter is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change.

A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559

Storing State of Collapsed Filters

Thanks for this project. I recently integrated these filter types and found that they currently don't match the style of Django 2.4.1.

I overrode the template filter_numeric_range.html with the following source:

{% load i18n %}

{% with choices.0 as choice %}
<details open>
    <summary>{% blocktrans with filter_title=title %} By {{ filter_title }}{% endblocktrans %} </summary>
    <form method="get" class="admin-numeric-filter-wrapper">
        {% for k, v in choice.request.GET.items %}
            {% if not k == choice.parameter_name|add:'_from' and not k == choice.parameter_name|add:'_to' %}
                <input type="hidden" name="{{ k }}" value="{{ v }}">
            {% endif %}
        {% endfor %}

        <div class="admin-numeric-filter-wrapper-group">
            {{ choice.form.as_p }}
        </div><!-- /.filter-numeric-filter-wrapper-group -->

        <button type="submit" class="submit">{% trans 'Apply' %}</button>
    </form>
</details>
{% endwith %}

As you can see the "summary" and "details" elements are present. Mind the spaces before/after the summary text content.

Unfortunately, collapsing works but restoring after a reload not.

I think this would be a valuable addition to this plugin.

Missing wNumb javascript mapping causes collectstatic crash

Since Django 4.0, collectstatic post-processes source maps found in js files. See this django ticket.
The file wNumb.min.js contains this:

//# sourceMappingURL=wNumb.min.js.map

However the map does not exist. So either generate the map or remove this line.
Currently this prevents everyone using ManifestStaticFilesStorage from running collectstatic cause it crashes.

one apply button

Can I set all changes and have just one APPLAY button to filter all ?

Max bound with SliderNumericFilter.choices DecimalField

My custom slider:

class CustomSliderNumericFilter(SliderNumericFilter):
    MAX_DECIMALS = 2
    field = DecimalField()

Result of SliderNumericFilter choices method:

({
'decimals': 2, 
'step': 0.01, 
'parameter_name': 'total_amount',
'request': <WSGIRequest: GET '/admin/base/saleorder/'>,
'min': Decimal('20.45'),
'max': Decimal('315.05'), <---
'value_from': Decimal('20.45'), 
'value_to': Decimal('315.05'), <----
'form': <SliderNumericForm bound=True, valid=Unknown, fields=(total_amount_to)>
},)

max and value_to are correct but as you can see in form the max value is wrong. It should be 315.05 instead of 315.00
slidernumericfilter

Did i miss something ?

Error in slider with only one record

nouislider.min.js:3 Uncaught Error: noUiSlider (11.1.0): 'range' 'min' and 'max' cannot be equal.
    at Object.G [as t] (nouislider.min.js:3)
    at nouislider.min.js:3
    at Array.forEach (<anonymous>)
    at X (nouislider.min.js:3)
    at Object.Z [as create] (nouislider.min.js:3)
    at admin-numeric-filter.js:6
    at Array.forEach (<anonymous>)
    at HTMLDocument.<anonymous> (admin-numeric-filter.js:2)

Formatting options for numbers

It would be nice to have the ability to format the numbers displayed on the filter UI. For example, if the numbers represent currency, or to add comma separators, etc.

I have error ImportError

Hello. I want to use your number range filter, but I got error:
ImportError: cannot import name ‘ugettext_lazy’ from ‘django.utils.translation’

["“['x']” value must be a decimal number."]

Hello,

after upgrading to Django 5.x I am getting errors using all the filters (e.g. SingleNumericFilter and RangeNumericFilter).

No matter what I input, I alwas get this error:

["“['x']” value must be a decimal number."]

where 'x' is any number I put (could be 0, 100, 1000).

Full stack:

Environment:


Request Method: GET
Request URL: .../?e=1&project_number_from=1&project_number_to=6786

Django Version: 5.0.4
Python Version: 3.11.2
Installed Applications:
['admin_numeric_filter',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'admin_auto_filters',
 'mod_wsgi.server',
 'artsdb',
 'choices',
 'import_export',
 'django_select2',
 'djmoney',
 'smart_selects']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/fields/__init__.py", line 1805, in to_python
    decimal_value = decimal.Decimal(value)
                    ^^^^^^^^^^^^^^^^^^^^^^

During handling of the above exception (argument must be a sequence of length 3), another exception occurred:
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/contrib/admin/options.py", line 716, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/utils/decorators.py", line 188, in _view_wrapper
    result = _process_exception(request, e)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/utils/decorators.py", line 186, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/contrib/admin/sites.py", line 240, in inner
    return view(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/import_export/admin.py", line 667, in changelist_view
    return super().changelist_view(request, extra_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/import_export/admin.py", line 872, in changelist_view
    return super().changelist_view(request, extra_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/import_export/admin.py", line 69, in changelist_view
    return super().changelist_view(request, extra_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/utils/decorators.py", line 48, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/utils/decorators.py", line 188, in _view_wrapper
    result = _process_exception(request, e)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/utils/decorators.py", line 186, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/contrib/admin/options.py", line 1985, in changelist_view
    cl = self.get_changelist_instance(request)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/contrib/admin/options.py", line 864, in get_changelist_instance
    return ChangeList(
           
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/contrib/admin/views/main.py", line 144, in __init__
    self.queryset = self.get_queryset(request)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/contrib/admin/views/main.py", line 547, in get_queryset
    new_qs = filter_spec.queryset(request, qs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/admin_numeric_filter/admin.py", line 97, in queryset
    return queryset.filter(**filters)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/djmoney/models/managers.py", line 207, in wrapper
    queryset = func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/query.py", line 1476, in filter
    return self._filter_or_exclude(False, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/query.py", line 1494, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/query.py", line 1501, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1613, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1645, in _add_q
    child_clause, needed_inner = self.build_filter(
                                 
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1559, in build_filter
    condition = self.build_lookup(lookups, col, value)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1389, in build_lookup
    lookup = lookup_class(lhs, rhs)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/lookups.py", line 30, in __init__
    self.rhs = self.get_prep_lookup()
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/lookups.py", line 88, in get_prep_lookup
    return self.lhs.output_field.get_prep_value(self.rhs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/fields/__init__.py", line 1829, in get_prep_value
    return self.to_python(value)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py_ptracker/lib/python3.11/site-packages/django/db/models/fields/__init__.py", line 1807, in to_python
    raise exceptions.ValidationError(
    ^

Exception Type: ValidationError at /admin/artsdb/project/
Exception Value: ["“['1']” value must be a decimal number."]

Slider filter says "not enough data" when there is a 0 value

I have a collection of entities with a value that can have value 0, and would wish to filter them using this utility. However, when one has value 0, the slider disappears and says there's not enough data. In the example shown below, if I change the second entity's "Coste de ingeniería" value to any positive value, the filter works as intended.
Anotación 2019-08-20 113626

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.