Skip to main content

A key word based queryset search for django

Project description

Django Fine Search

https://github.com/bellomusodiq/dj-fine-search

https://pypi.org/project/dj-fine-search/

Django fine search is package that performs search based on keywords. It allows word flexibility for performing filter in a queryset. e.g. The native Model.object.filter(title__icontains='hello world') will return queryset of objects that contains substring "hello world", if the "world" comes before the "hello", the objects would not be found. Django fine search improves that, Django fine search will include all objects that has substring "hello world".

class MyModel(models.Model):    
    title = models.Charfield(max_length=200)
    text = models.TextField()
    ...

perform_search takes in the model, search_text and fields

model: Model class, the model to perform filter on

search_text: string, the query that will be used for the filtering

fields: list or tuple of the fields of the models that the search will be performed on e.g. title and text above

perform_search function returns a list of model objects

>> pip install dj-fine-search
from fine_search.fine_search import perform_search
# model based search
queryset = perform_search(model=MyModel, search_text='hello world', fields=["title", "text"])
# assume we have the queryset below are result of MyModel.objects.all()
queryset = [{"id": 1, "title": "some title", "text": "hello world, how are you"},
            {"id": 2, "title": "some title2", "text": "the world is good"}, 
            {"id": 3, "title": "some title3", "text": "world hello there, hello"}] 
# if we run perform_search on the MyModel with search_text='hello world' and fields=['title', 'fields']

# it will return all the queries

it is also possible to perform search on queryset. e.g. queryset that has been filter initialy

from fine_search.fine_search import perform_search_queryset

q = MyModel.objects.all()

queryset = perform_serach_queryset(queryset=q, search_text='hello world', fields=["title", "text"])

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

dj-fine-search-0.0.4.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

dj_fine_search-0.0.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file dj-fine-search-0.0.4.tar.gz.

File metadata

  • Download URL: dj-fine-search-0.0.4.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for dj-fine-search-0.0.4.tar.gz
Algorithm Hash digest
SHA256 14944e857a42eead9c14ac44837c34e79f59e25e7589e05c5216e0429c2c9252
MD5 69b4591c0965efbe2468fb66f5c32ec5
BLAKE2b-256 17165fe544c8df5bc8be39b35ede7d549dd9935b60d2bfb7765c15c1c713b903

See more details on using hashes here.

File details

Details for the file dj_fine_search-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: dj_fine_search-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for dj_fine_search-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 14261a67c796f14b4cfe42a4084521120e17b62f279e687cf836b5cfd8a84b90
MD5 9a819acf76d7fbb56b5a22e609eb5727
BLAKE2b-256 667acd6b6fe789c831e9ca23274f9016f40173dbd31c724cf04b57c0a356d7ce

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