File: haystack_info.py

package info (click to toggle)
django-haystack 3.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,504 kB
  • sloc: python: 23,475; xml: 1,708; sh: 74; makefile: 71
file content (22 lines) | stat: -rw-r--r-- 766 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from django.core.management.base import BaseCommand

from haystack import connections
from haystack.constants import DEFAULT_ALIAS


class Command(BaseCommand):
    help = "Provides feedback about the current Haystack setup."  # noqa A003

    def handle(self, **options):
        """Provides feedback about the current Haystack setup."""

        unified_index = connections[DEFAULT_ALIAS].get_unified_index()
        indexed = unified_index.get_indexed_models()
        index_count = len(indexed)
        self.stdout.write("Number of handled %s index(es)." % index_count)

        for index in indexed:
            self.stdout.write(
                "  - Model: %s by Index: %s"
                % (index.__name__, unified_index.get_indexes()[index])
            )