Skip to main content

Quick search anything in Django Admin from a single place

Project description

djangomni-search

Django Admin Site extension, that allows searching all entities from single field

Installation

Please read the instructions carefully, extending Django Admin on this level can go wrong very easily.

1. Pip your deps

Basically, install the dependency. You can use poetry, or any other package manager.

pip install djangomni-search

2. Put djangomni_search into INSTALLED_APPS

It is important to put it on the top.

INSTALLED_APPS = [
    'djangomni_search',
    'django.contrib.admin',
    'django.contrib.auth',
    '...',
]

3. Configure Admin Site

Now you will need to configure your Admin Site(s) to inherit from djangomni_search.admin.OmniSearchAdminSite. If you're using the default AdminSite, you must create a custom one.

class SiteAdmin(OmniSearchAdminSite, AdminSite):
    ...

4. Extend your custom base_site.html

If you do not have a custom base_site.html, it should already work. In case you have done some customizations to your base site file, you will need to add one script to all pages in admin. This can be only done by extending the base template.

{% block extrahead %}
{% if omni_search %}
  <link
    href="{% static 'djangomni-search/main.css' %}"
    rel="stylesheet"
    type="text/css"
  />
  <script
    data-config="{{omni_search}}"
    id="djangomni-search"
    src="{% static 'djangomni-search/main.js' %}"
  ></script>
{% endif %}
{% endblock %}

5. Configure autocomplete

The Omni Search looks for data using the autocomplete_fields attribute of ModelAdmin. Configure it for all the models, that you want to search.

Examples

Go to the ../dev-site implementation, it serves as example page.

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

djangomni_search-0.3.0.tar.gz (71.7 kB view details)

Uploaded Source

File details

Details for the file djangomni_search-0.3.0.tar.gz.

File metadata

  • Download URL: djangomni_search-0.3.0.tar.gz
  • Upload date:
  • Size: 71.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for djangomni_search-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7b2543ac4953b8e91f89f1fcd9662d68b05c2d86ba5ec56ff1f975b35279ff0e
MD5 6bddb2c740b22aab6b5d4007ac466521
BLAKE2b-256 9c4536dfb73b412bf97f853f759459add105d29978145b6d7157ec5bdb4ee755

See more details on using hashes here.

Supported by

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