Django Admin Search
The "Django Admin Search" is a advanced search modal for django admin.
If you use or like the project, click Star and Watch to generate metrics and i evaluate project continuity.
Install:
pip install django-admin-search
Usage:
-
Add to your INSTALLED_APPS, in settings.py:
INSTALLED_APPS = [ ... 'django_admin_search', ... ] -
Create a search form for model:
from .models import Area from django.forms import ModelForm, Form from django.forms import DateField, CharField, ChoiceField, TextInput class YourFormSearch(Form): name = CharField(required=False) date = DateField(required=False, widget=TextInput( attrs={ 'filter_method': '__gte', } )) -
In your admin:
from django_admin_search.admin import AdvancedSearchAdmin from .models import YourModel from .form import YourForm, YourFormSearch @register(YourModel) class YourAdmin(AdvancedSearchAdmin): form = YourForm search_form = YourFormSearch
Advanced:
-
to multiple filters in same field:
class YourFormSearch(Form): ... name = CharField(required=False) begin = DateField(required=False, widget=TextInput( attrs={ 'filter_field': 'date', 'filter_method': '__gte', } )) end = DateField(required=False, widget=TextInput( attrs={ 'filter_field': 'date', 'filter_method': '__lte', } )) -
add placeholder and mask
class YourFormSearch(Form): ... date = DateField(required=False, widget=TextInput( attrs={ 'data-mask': "00/00/0000", 'placeholder': 'MM/DD/YYYY' } )) -
Custom filter query for a field
from django_admin_search.admin import AdvancedSearchAdmin from .models import YourModel from .form import YourForm, YourFormSearch @register(YourModel) class YourAdmin(AdvancedSearchAdmin): def search_FieldNameHere(request, field_value, param_values): """ intercept query filter for description field """ query = Q() # your Q logic here return query
Images:
Button in admin list:
Modal opened:
Development and Running the Tests
To do development work for Django Admin Search, clone it locally, make and activate a virtualenv for it, then from within the project directory:
pip install -e ".[dev]"
To run the tests:
pytest
If your work in high difficult test, and need to re run the test every time, use pytest-watch:
ptw # this see file change and re run a test
when you need to see passed lines by test, run
pytest --cov-report html
after this, will be created a htmlcov folder in the root
To run sonar
pytest --cov-report xml
pylint ./django_admin_search/ --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" | tee pylint.txt
sonar-scanner
See your code quality in Sonar (in testing, no metrics to approve yet)
https://sonarcloud.io/dashboard?id=shinneider_django-admin-search
For future i want to run test's in Travis CI, to check if PR is Ok, but to be effective, i need to cover 80% or more of the code, help-me creating a test case, see this issue PR - 20
Need a Maintainer
In the last months i don't have much time, health problemas, change of country and others problems.
i have some surgeries for first part of 2022, and all of my current project don't use django-admin.
for these reasons, i need a help for a project continuation!!
Metadata
Release files for django-admin-search 0.3.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-admin-search-0.3.15.tar.gz | 49.5 kB | Without provenance | Details for django-admin-search-0.3.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_admin_search-0.3.15-py3-none-any.whl | Python 3 | none | any | Details for django_admin_search-0.3.15-py3-none-any.whl |
Total release size: 100.1 kB
Release files / django-admin-search-0.3.15.tar.gz
| Download URL | django-admin-search-0.3.15.tar.gz |
|---|---|
| Size | 49.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75e457895a654d29db34379bde2228ce1b12b1e58150c13025a9d19ee22a4f2a
|
|
BLAKE2b-256 checksum How to use checksums |
e779f38ca6bd8a0629c2ce9ac91aa0133dd671abd0b40bc17817eaf41d75a0d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Release files / django_admin_search-0.3.15-py3-none-any.whl
| Download URL | django_admin_search-0.3.15-py3-none-any.whl |
|---|---|
| Size | 50.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9edd1b2a199aea245a6bbe495744dba0831269b4ce687441f7140e38476fc84
|
|
BLAKE2b-256 checksum How to use checksums |
8482206ea84bb747f9dc16348aa51ae5e860d5050fae20fe5e414f556287c906
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Security for django-admin-search 0.3.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.