algoliasearch-django-example
.
- Compatible with Python 3.8 or later.
- Supports Django 4 and 5.
Install
Setup
In your Django settings, addalgoliasearch_django
to INSTALLED_APPS
and add these two settings:
Python
-
INDEX_PREFIX
A prefix for all indices. Use it to separate different applications, likesite1_Products
andsite2_Products
. -
INDEX_SUFFIX
A suffix for all indices. Use it to differentiate development and production environments, such asLocation_dev
andLocation_prod
. -
AUTO_INDEXING
If true (default), models are automatically synced with Algolia. -
RAISE_EXCEPTIONS
Raise exceptions for network errors instead of logging them (default tosettings.DEBUG
).
Quickstart
Create anindex.py
inside each application with the models you want to index.
Inside this file, call algoliasearch.register()
for each model you want to index:
Python
AlgoliaIndex
and using the register
decorator:
Python
Connection errors
If you get one of these errors:Impossible to connect
, Unable to connect
,
or Unreachable hosts
:
- Ensure you’re using the correct application ID and API key. You can find your credentials on your Algolia dashboard.
- Check for recent changes in your code.
- Check the status of your data center provider.
If you’re using Firebase, you can only access Algolia from a paid Firebase tier.
- The name of your framework integration (Django) and its version number
- A code snippet to reproduce the issue
- Error message or stack trace (if applicable)
- The name of the Algolia index that’s causing problems
- The exact UTC time of the event
-
If you can’t connect to the Algolia API from your browser, send the output from
community.algolia.com/diag
. -
If you can’t connect to the Algolia API from your servers, send the output from the following command (run on any affected server):
Replace
ALGOLIA_APPLICATION_ID
with your Algolia application ID.Indexing errors
AnyRecord at the position XX objectID=XX is too big
errors during indexing are because you exceeded the size limit for records.
Reduce the size of your records and try again.