Skip to main content

Your project description goes here

Project description

https://badge.fury.io/py/django-admin-fast-search.svg https://travis-ci.org/utkbansal/django-admin-fast-search.svg?branch=master https://codecov.io/gh/utkbansal/django-admin-fast-search/branch/master/graph/badge.svg

Your project description goes here

Documentation

The full documentation is at https://django-admin-fast-search.readthedocs.io.

Quickstart

Install django-admin-fast-search:

pip install django-admin-fast-search

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'django_admin_fast_search',
    ...
)

Use it in your Django admin for search fields:

from django_admin_fast_search.admin import FastSearch

class MyModelAdmin(FastSearch, admin.ModelAdmin):
    list_display = ['name', 'email']

    search_fields_contains = ("address",)
    search_fields_exact = ("id", "email")
    search_fields_fulltext_index = ("name",)
    search_fields = search_fields_fulltext_index + search_fields_exact + search_fields_contains

Use it for list filters with django_filters

from django_filters import BooleanFilter, FilterSet
from django_admin_fast_search.admin import FastSearchFilterMixin

class MyModelFilter(FastSearchFilterMixin, FilterSet):
    is_verified = BooleanFilter(label="Verified?")

    company_name = CharFilter(field_name="company__name", lookup_expr="icontains")
    company_pincode = CharFilter(field_name="company__location_pincode", lookup_expr="exact")

    exclude_industry = CharFilter(field_name="industry", lookup_expr="icontains", label="Exclude Industry", exclude=True)

    status = MultipleChoiceFilter(
        field_name="status",
        lookup_expr="exact",
        label="Status",
        choices=MyModel.STATUS_CHOICES,
    )

    created_at = DateFilter(field_name="created_at", lookup_expr="gt", label="Signed up After")

    class Meta:
        model = MyModel
        fields = [
            "is_verified",
            "company_name",
            "company_pincode",
            "exclude_industry",
            "status",
            "created_at",
        ]


class MyModelAdmin(FastSearch, admin.ModelAdmin):
    list_display = ['name', 'email']

    list_filter = ["company_tier", *MyModelFilter.as_admin_filters()]

    # or only use class-based filters

    list_filter = MyModelFilter.as_admin_filters()

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Development commands

pip install -r requirements_dev.txt
invoke -l

Credits

Tools used in rendering this package:

History

0.1.2 (2022-05-30)

  • Add classifiers for Python 3.7, 3.8, 3.9, 3.10

  • Remove support for Python 2, 2.7, 3.5, 3.6

  • Automate publish to PyPi

0.1.0 (2021-05-22)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_admin_fast_search-0.2.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_admin_fast_search-0.2.1-py2.py3-none-any.whl (11.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django_admin_fast_search-0.2.1.tar.gz.

File metadata

  • Download URL: django_admin_fast_search-0.2.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.4

File hashes

Hashes for django_admin_fast_search-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a5c5b4a7ff9869dd6a379633744db5f29da3766535251f2f299fd1c791b54536
MD5 1bd3be5adaec4bf72c5dba6107a08210
BLAKE2b-256 dbce5fc43e2e8898356a9870ce6e956682b3304a066f103edd97d0c06b0338c5

See more details on using hashes here.

File details

Details for the file django_admin_fast_search-0.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_fast_search-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 aa8bce30849e62d080caeed79b6f1259d1010d2fe37e693d55aaec6787808aaa
MD5 4d694d5be626c5ccb70d548c57977bac
BLAKE2b-256 862c9b53938a5d7d72d71d2d2fe8a196819b4a089e252e3ce57d394e551bd65c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page