MCPcopy Create free account
hub / github.com/django-haystack/django-haystack / __init__

Method __init__

haystack/indexes.py:453–483  ·  view source on GitHub ↗
(self, extra_field_kwargs=None)

Source from the content-addressed store, hash-verified

451 fields_to_skip = (ID, DJANGO_CT, DJANGO_ID, "content", "text")
452
453 def __init__(self, extra_field_kwargs=None):
454 super().__init__()
455
456 self.model = None
457
458 self.prepared_data = None
459 content_fields = []
460 self.extra_field_kwargs = extra_field_kwargs or {}
461
462 # Introspect the model, adding/removing fields as needed.
463 # Adds/Excludes should happen only if the fields are not already
464 # defined in `self.fields`.
465 self._meta = getattr(self, "Meta", None)
466
467 if self._meta:
468 self.model = getattr(self._meta, "model", None)
469 fields = getattr(self._meta, "fields", [])
470 excludes = getattr(self._meta, "excludes", [])
471
472 # Add in the new fields.
473 self.fields.update(self.get_fields(fields, excludes))
474
475 for field_name, field in self.fields.items():
476 if field.document is True:
477 content_fields.append(field_name)
478
479 if not len(content_fields) == 1:
480 raise SearchFieldError(
481 "The index '%s' must have one (and only one) SearchField with document=True."
482 % self.__class__.__name__
483 )
484
485 def should_skip_field(self, field):
486 """

Callers

nothing calls this directly

Calls 4

get_fieldsMethod · 0.95
SearchFieldErrorClass · 0.85
__init__Method · 0.45
updateMethod · 0.45

Tested by

no test coverage detected