GithubHelp home page GithubHelp logo

shinneider / django-admin-search Goto Github PK

View Code? Open in Web Editor NEW
75.0 75.0 21.0 245 KB

Modal filter for django admin

License: MIT License

Python 81.11% HTML 14.46% CSS 4.43%
django django-admin filter filters modal search

django-admin-search's People

Contributors

abhi904485 avatar anuj-scanova avatar dependabot[bot] avatar franciscoda avatar gabbyprecious avatar naggafin avatar shinneider avatar shinneider-ivory avatar yuriescl 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

Watchers

 avatar  avatar  avatar  avatar  avatar

django-admin-search's Issues

Improve tests

in the version 0.3.2 I added some tests, but the core django_admin_search/admin.py is not tested yet, need to cover this.

to elaborate test cases for this can be tricky.

Support for dark mode

As of Django 3.2 automatic dark mode is supported.
This project is clearly not compatible:
scrot_20240424_132529

Please release 3.12

The most recent release on PyPI (3.11, untagged here on GitHub) doesn't include the most recent commits from January which are required for compatibility with Django 4. Please release a version 3.12 on PyPI!

(In the meantime, anyone wanting to use this with Django 4 -- or silence the deprecation warnings with Django 3 -- can use pipenv install -e git+https://github.com/shinneider/django-admin-search@47245d8#egg=django-admin-search or similar.)

Edit `example` requirements to remove dependabot security warnings

In example folder, has a requirements.txt with django==2.2.4.

because of this, if community encoutered a new bug in this version, dependabot create a PR and a alert for me.

however is a example folder, i need to remove this, because is not a critical erro, example folder is not lib package.

I suggest change requirements to wildcard version in minor and patch ex: django==2.*

Version 0.3.10 stopped working after recent 'simplifcation'

With this commit:

86463f7#diff-87b0e17e051db518901ad65521b336894bf5652a42e5fc1f8e6ffea9896b8930

Method get_field_override was renamed into get_field_value, but there is already get_field_value on a class with a completely different signature, this makes the code explode with message: "Filter not applied, error has occurredget_field_value() missing 4 required positional arguments: 'form_field', 'field_value', 'has_field_value', and 'request'"

Replace js files to minified

jquery and jquery mask is not using a minified version.

because of that, the lib has size of 400kb, but 386kb is static js files.
Changing for minified, lib size decrese +/- 300kb.

Error installing with pip - Docker

Hi,

i currently updated to django-admin-search 0.3.8 and tried building my Container after that. It gets me following error:

#18 19.18   Downloading django-admin-search-0.3.8.tar.gz (49 kB)
#18 19.19   Preparing metadata (setup.py): started
#18 19.70   Preparing metadata (setup.py): finished with status 'error'
#18 19.70   ERROR: Command errored out with exit status 1:
#18 19.70    command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u2gyywqj/django-admin-search_6ace2ea415234adeb9a255046aacca76/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u2gyywqj/django-admin-search_6ace2ea415234adeb9a255046aacca76/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1m8huu2c
#18 19.70        cwd: /tmp/pip-install-u2gyywqj/django-admin-search_6ace2ea415234adeb9a255046aacca76/
#18 19.70   Complete output (7 lines):
#18 19.70   Traceback (most recent call last):
#18 19.70     File "<string>", line 1, in <module>
#18 19.70     File "/tmp/pip-install-u2gyywqj/django-admin-search_6ace2ea415234adeb9a255046aacca76/setup.py", line 7, in <module>
#18 19.70       from django_admin_search.meta import VERSION
#18 19.70     File "/tmp/pip-install-u2gyywqj/django-admin-search_6ace2ea415234adeb9a255046aacca76/django_admin_search/__init__.py", line 2, in <module>
#18 19.70       from django import __version__ as django_version
#18 19.70   ModuleNotFoundError: No module named 'django'
#18 19.70   ----------------------------------------
#18 19.70 WARNING: Discarding https://files.pythonhosted.org/packages/4c/6b/3603e90207855c7414386c20d0662f6a6a2ad18e6441a70f00c6614750b6/django-admin-search-0.3.8.tar.gz#sha256=f1b248b5e1706a75e64597b3eb21efd212576ac06eaec608bb0633e112b0d911 (from https://pypi.org/simple/django-admin-search/) (requires-python:>=3.3). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#18 19.70 ERROR: Could not find a version that satisfies the requirement django-admin-search==0.3.8 (from versions: 0.1.1, 0.2.2, 0.3, 0.3.1, 0.3.3, 0.3.5, 0.3.6, 0.3.7, 0.3.8)
#18 19.70 ERROR: No matching distribution found for django-admin-search==0.3.8

i moved django before django-admin-search in the requirements.txt but it didn't help.

This is my command for pip pip install -r requirements.txt --no-cache-dir

Do you have an idea what i could do here?

Best Regards

Fabian

Refact advanced_search_query function

I want to refactor advanced_search_query function inside django_admin_search/admin.py

Because is a very large function, is hard to maintenance and developer test cases.

This function is responsible for:
- allow to create a custom filter for especific field (line 63 to 71)
- get field and filter method (73 and 74)
- apply default filter (76 to 92)

I sugeste create a specific function for all this methods.

Create static subfolder for app

The static folder should have a subfolder named django_admin_search to avoid conflicting with already existing static files when running python manage.py collectstatic.

Filters works only in the first page

Diff to easy simulate erro

--- a/example/app/example/admin.py
+++ b/example/app/example/admin.py
@@ -11,6 +11,7 @@ from .models import Area
 class AreaAdmin(AdvacedSearchAdmin):
     form = AreaForm
     search_form = AreaSearchForm
+    list_per_page = 1

Create a 2 or more entries, after this change for another page (other than the first), and try to user advanced filter modal, nothing happens. not filters applied no errors in browser console or python.

Improve checkbox format

Currently checkbox field has no format (css styles), however all other field are be formatted, i suggest format this field too.

But no have ideia for this field format

Simple stylized checkbox ?
Toggle field format ?
Transform in select field with options True and False ?

Pagination does not carry filter parameters

Describe the bug

Pagination does not carry filter parameters.

Steps to reproduce

  1. Input filter parameters
    http://127.0.0.1:8000/admin/reports/tpareports/?date_start=2012-09-26&date_end=2028-09-26

  2. Pagination is still original

image

Details

OS: Windows 10/Alpine Linux v3.13
Python version 3.6
Django version 3.1.3
django-admin-search version 0.3.11
Browser Chrome

Add

This plugin is great. I can't fix it because I'm a Django beginner.
I appreciate your contribution whether you fix this or not.

Refresh issue after returning from search form

Once the search is over, the page doens't refresh to return back the original set of records. Please check the url even after we remove the parameters, we don't get the original expected rows in the modeladmin view, until we make some changes in the python code and save it.

Allow empty or null ChoiceField

If a ChoiceField is added to the search form, when the search is made, the choice field always gets into the queryset with the first value as default selected.

It is not always necessary that the search should include the value from the ChoiceField.

It is possible to allow empty or null value to the Choice field and it should be added to the queryset if is not null?

Login based search queryset to be returned.

  1. Login based queryset object to be returned.
    Since this tool overrides the default django queryset object already, how to return the only customer domain based specific records as default , when not searched.
    eg: ```
    def get_queryset(self, request):
    domain_list = []
    temp = []
    qs = super(LogSearchFormAdmin, self).get_queryset(request)
    if request.user.is_superuser:
    return qs
    else:
    domain_list = Domain.objects.filter(
    customer__in=Customer.objects.filter(
    email=request.user.username)).values_list(
    'name', flat=True)
    #print(list(domain_list))
    dom_names = list(domain_list)
    #print(dom_names)
    qs = MailLogs.objects.none()
    if dom_names:
    for d in dom_names:
    qs = MailLogs.objects.filter(
    Q(mfrom__icontains=d)|Q(mto__icontains=d))

             # qs |= MailLogs.objects.filter(mfrom__icontains=d)
    
             # qs |=  MailLogs.objects.filter(mto__icontains=d)
    
             print(qs.query)
     #print(qs)
     return qs
    

Issue in filtering the attributes with null value.

Hi,
There are two issues:

  1. There is an issue in filtering the attributes with null value.
  2. Always need to include __contains in CharField.

Example:

#models.py
class Emp(models.Model):
    first_name = models.CharField(blank=False, null=False, max_length=100)
    last_name = models.CharField(blank=True, null=True, default=None, max_length=100)

#search form
class EmpSearchForm(forms.Form):
   
    first_name = forms.CharField(
        required=False,
        widget=forms.TextInput(
            attrs={
                'filter_method': '__contains',
            }
        )
    )
    
    last_name = forms.CharField(
          required=False
      )
  1. If we want to filter only by first_name. The filter does not return any result when the value of last_name is null.

  2. If we want to filter only by first_name, then the above search form does not return any result because last_name's filter_method is not set to __contains. The generated URL is:

    emp/?first_name=John&last_name=

    Setting last_name's filter_method to __contains will work fine.

    last_name = forms.CharField(
       required=False,
       widget=forms.TextInput(
           attrs={
               'filter_method': '__contains',
           }
       )
    )

suggestion:

  1. We can ignore the filter whose value is not passed or empty in the query parameter.
    e.g., for emp/?first_name=John&last_name= filter should work only on first_name as the last_name is empty so it should be ignored.

Recreate field's layout's

currently all fields occupy 100% of the line, I suggest having field options occupying only half the line (for accept two field by line).

in this issue is interesting to improve the spacing between label and field also.

The file django_admin_search/templates/admin/custom_fieldset.html is responsable by field html, to find css follow the issue 22 .

Move css inside a html to external file

In the file django_admin_search/templates/admin/custom_search_form.html has many lines of css.

i need to move this lines of css, to a external css file, loaded in the html

Add classifiers in setup.py

according pip (https://pypi.org/classifiers/)

Each project's maintainers provide PyPI with a list of "trove classifiers" to categorize each release, describing who it's for, what systems it can run on, and how mature it is.

These standardized classifiers can then be used by community members to find projects based on their desired criteria.

fix name change advaced to advanced

This is a grammatical error, it needs to be corrected

Files to be changed:

README.md
Line(s) -> 48, 53, 92, 97

django_admin_search/admin.py
Line(s) -> 9

django_admin_search/templates/admin/custom_search_form.html
Line(s) -> 69, 103, 135

example/app/example/admin.py
Line(s) -> 4, 11

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.