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
Copy file name to clipboardExpand all lines: README.md
+15-17Lines changed: 15 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ This package lets you easily integrate the Algolia Search API to your [Django](h
13
13
14
14
You might be interested in this sample Django application providing a typeahead.js based auto-completion and Google-like instant search: [algoliasearch-django-example](https://github.com/algolia/algoliasearch-django-example)
15
15
16
-
Compatible with **Python 2.7**, **Python 3.3+** and **Django 1.7+**
16
+
Compatible with **Python 2.7**, **Python 3.4+** and **Django 1.7+**
17
17
18
18
19
19
@@ -66,7 +66,7 @@ This package lets you easily integrate the Algolia Search API to your [Django](h
66
66
67
67
You might be interested in this sample Django application providing a typeahead.js based auto-completion and Google-like instant search: [algoliasearch-django-example](https://github.com/algolia/algoliasearch-django-example)
68
68
69
-
Compatible with **Python 2.7**, **Python 3.3+** and **Django 1.7+**
69
+
Compatible with **Python 2.7**, **Python 3.4+** and **Django 1.7+**
70
70
71
71
## Install
72
72
@@ -94,39 +94,36 @@ There are several optional settings:
94
94
95
95
## Quick Start
96
96
97
-
Simply call `algoliasearch.register()` for each of the models you want to index. A good place to do this is in your application's AppConfig (generally named `apps.py`). More info in the [documentation](https://docs.djangoproject.com/en/1.8/ref/applications/)
97
+
Create an `index.py` inside each application that contains the models you want to index.
98
+
Inside this file, call `algoliasearch.register()` for each of the models you want to index:
98
99
99
100
```python
100
-
from django.apps import AppConfig
101
+
# index.py
102
+
101
103
import algoliasearch_django as algoliasearch
102
104
103
-
classYourAppConfig(AppConfig):
104
-
name ='your_app'
105
+
from .models import YourModel
105
106
106
-
defready(self):
107
-
YourModel =self.get_model('your_model')
108
-
algoliasearch.register(YourModel)
107
+
algoliasearch.register(YourModel)
109
108
```
110
109
111
-
And then, don't forget the line below in the `__init__.py` file of your Django application.
110
+
By default, all the fields of your model will be used. You can configure the index by creating a subclass of `AlgoliaIndex` and using the `register` decorator:
By default, all the fields of your model will be used. You can configure the index by creating a subclass of `AlgoliaIndex`. A good place to do this is in a separate file, like `index.py`.
115
+
from algoliasearch_django importAlgoliaIndex, register
118
116
119
-
```python
120
-
from algoliasearch_django import AlgoliaIndex
117
+
from .models import YourModel
121
118
119
+
@register(YourModel)
122
120
classYourModelIndex(AlgoliaIndex):
123
121
fields = ('name', 'date')
124
122
geo_field ='location'
125
123
settings = {'searchableAttributes': ['name']}
126
124
index_name ='my_index'
127
-
```
128
125
129
-
And then replace `algoliasearch.register(YourModel)` with `algoliasearch.register(YourModel, YourModelIndex)`.
126
+
```
130
127
131
128
132
129
@@ -412,3 +409,4 @@ class OverrideSettingsTestCase(TestCase):
0 commit comments