You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support indexing models in multiple applications with different APPLICATION_ID and API_KEY settings on a per-model basis while preserving the native register and hooks integration.
Django version: 1.11
Algolia Django integration version: 2.0.0
Algolia Client Version: 2.6.1
Language Version: Python 3.9
How this could work
Subclass AlgoliaEngine or modify the @register decorator. Not really show how the implementation details would work but here is some pseudocode to convey the general idea.
classScholarshipAlgoliaEngine(AlgoliaEngine)
scholarship_algolia_settings= {
**settings.ALGOLIA,
'APPLICATION_ID': env['SCHOLARSHIP_ALGOLIA_APPLICATION_ID'],
'API_KEY': env['SCHOLARSHIP_ALGOLIA_API_KEY'],
}
def__init__(self, settings=scholarship_algolia_settings, *args, **kwargs):
super().__init__(self, settings=settings, *args, **kwargs) # args and kwargs not needed but maybe for backwards-compatibility?@register(Scholarship, ScholarshipAlgoliaEngine)classScholarshipIndex(AlgoliaIndex):
pass# OR@register(Scholarship)classScholarshipIndex(AlgoliaIndex, ScholarshipAlgoliaEngine):
pass# ORcustom_engine=ScholarshipAlgoliaEngine()
@custom_engine.register(Scholarship)classScholarshipIndex(AlgoliaIndex):
pass
Description
Support indexing models in multiple applications with different
APPLICATION_ID
andAPI_KEY
settings on a per-model basis while preserving the native register and hooks integration.How this could work
Subclass
AlgoliaEngine
or modify the@register
decorator. Not really show how the implementation details would work but here is some pseudocode to convey the general idea.Sources
Based on registration.py:
algoliasearch-django/algoliasearch_django/registration.py
Lines 28 to 33 in e192aec
and Algolia engine:
algoliasearch-django/algoliasearch_django/__init__.py
Lines 16 to 22 in e192aec
Another idea for how to implement this
Any models that don't have
APPLICATION_ID
orAPI_KEY
provided would use the default settings in settings.py:The text was updated successfully, but these errors were encountered: