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
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.1.5.tar.gz
.
File metadata
- Download URL: django_better_search-0.1.5.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94fff37637ed5767dfee2a6d0026f6e4def155c89b2a8ed8c3aa23a7079c3dd3 |
|
MD5 | e4728ff878cde0de5b9de5cbfd654370 |
|
BLAKE2b-256 | 3f73924f7567135088d141ca9af91ef7a643d96fd3401e240a43726a33c5094d |
File details
Details for the file django_better_search-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: django_better_search-0.1.5-py3-none-any.whl
- Upload date:
- Size: 6.6 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 | 5efda41906850c1771280fee3b421236a07f610df2ae6f561e2c45b1162a3fc2 |
|
MD5 | e2cf698799ff419c5a34c209e025f39e |
|
BLAKE2b-256 | 3f72a02bfe794bc98d2aacb3ad5ff748b89b601305fe79095759c20baf544607 |