Skip to content

Commit 41859e5

Browse files
Update README [skip ci]
1 parent dd4d8e3 commit 41859e5

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This package lets you easily integrate the Algolia Search API to your [Django](h
1313

1414
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)
1515

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+**
1717

1818

1919

@@ -66,7 +66,7 @@ This package lets you easily integrate the Algolia Search API to your [Django](h
6666

6767
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)
6868

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+**
7070

7171
## Install
7272

@@ -94,39 +94,36 @@ There are several optional settings:
9494

9595
## Quick Start
9696

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:
9899

99100
```python
100-
from django.apps import AppConfig
101+
# index.py
102+
101103
import algoliasearch_django as algoliasearch
102104

103-
class YourAppConfig(AppConfig):
104-
name = 'your_app'
105+
from .models import YourModel
105106

106-
def ready(self):
107-
YourModel = self.get_model('your_model')
108-
algoliasearch.register(YourModel)
107+
algoliasearch.register(YourModel)
109108
```
110109

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:
112111

113112
```python
114-
default_app_config = 'your_django_app.apps.YourAppConfig'
115-
```
113+
# index.py
116114

117-
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 import AlgoliaIndex, register
118116

119-
```python
120-
from algoliasearch_django import AlgoliaIndex
117+
from .models import YourModel
121118

119+
@register(YourModel)
122120
class YourModelIndex(AlgoliaIndex):
123121
fields = ('name', 'date')
124122
geo_field = 'location'
125123
settings = {'searchableAttributes': ['name']}
126124
index_name = 'my_index'
127-
```
128125

129-
And then replace `algoliasearch.register(YourModel)` with `algoliasearch.register(YourModel, YourModelIndex)`.
126+
```
130127

131128

132129

@@ -412,3 +409,4 @@ class OverrideSettingsTestCase(TestCase):
412409
```
413410

414411

412+

0 commit comments

Comments
 (0)