A different implementation of Django's admin search
Project description
django-better-search
This repo is heavily influenced by django-admin-search and copies some of the components as well.
This repo implements search on Django admin page differently. It generates different search boxes for separate fields and doesn't treat all of those fields as string.
Requirements
This app is tested using following:
- Django >= 3.2
- Python >= 3.9
Installation
This repo is published on Pypi. You can install it from there using following:
pip install django-better-search
Usage
Note: This project is not yet ready for production use.
- Add
django_separate_search
in yourINSTALLED_APPS
. Example:
INSTALLED_APPS = [
...
"django_separate_search",
...
]
- Create a search form to have search fields on your admin page. Example:
from django.forms import CharField, Form, IntegerField
class UserSearchForm(Form):
name = CharField(required=False, label="User's Name", help_text="Some help_text")
age = IntegerField(required=False, label="User's Age", help_text="Another help_text")
...
- Use the search form in your AppAdmin in your
admin.py
. Example:
from django_separate_search.admin import SeparateSearchAdmin
class UserAdmin(SeparateSearchAdmin):
...
search_form = UserSearchForm
...
This will render your search-form fields on the list-view admin page.
- If you want to implement search on a custom field, you will have to implement search_
<field_name>
. Example:
class UserAdmin(SeparateSearchAdmin):
...
def search_<field_name>(self, field, field_value, form_field, request, param_values):
query = Q()
// Implement your query
return query
Images
This is how search will look in admin view-list:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_better_search-0.2.0.tar.gz
.
File metadata
- Download URL: django_better_search-0.2.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aeee2015a4a7222205677db96921ba077f0946d66b05bf8b8253d166c7b83168 |
|
MD5 | b25d4a1af2283470e1cde03c015f12f0 |
|
BLAKE2b-256 | cd54d565663fcafa2264fdea19839e8dca2c9d19e1f07ee12432b1faa311b724 |
File details
Details for the file django_better_search-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: django_better_search-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 401078f00bd358709e0c4415e4b5f3e561f089501e63cd348a3de79623179933 |
|
MD5 | 2b733d60b673a2cebf08d82403ce8d52 |
|
BLAKE2b-256 | 9d00daa1f06d3d8ac1d46ed49970fdd18a48fc3aa60603637fd609dfff82c1ec |