Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-autocomplete-multi-models
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub
django-autocomplete-multi-models
Commits
d3b9db9e
Commit
d3b9db9e
authored
3 years ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
Update README.md
parent
b1f5d6fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+57
-1
57 additions, 1 deletion
README.md
with
57 additions
and
1 deletion
README.md
+
57
−
1
View file @
d3b9db9e
# django-autocomplete-multi-models
An app that index word used in text field across multiple model, and expose them to be searched.
\ No newline at end of file
An app that index word used in text field across multiple models, and expose an api to query for word similar to the query.
The app use django signals to be notified when an instance is changed and update its index with the new values.
Quick start
-----------
1.
Add "autocomplete_multi_models" at the end of your INSTALLED_APPS:
```
py
INSTALLED_APPS
=
[
...
'
autocomplete_multi_models
'
,
]
```
2.
Choose models and fields that you want to index:
```
py
AUTOCOMPLETE_TARGET_FIELDS
=
[
(
"
my_app
"
,
"
FirstModel
"
,
"
my_text_field
"
),
(
"
my_app
"
,
"
FirstModel
"
,
"
my_char_field
"
),
(
"
my_app
"
,
"
SecondModel
"
,
"
my_char_field
"
),
...
]
```
3.
Adjust settings
```
py
AUTOCOMPLETE_MIN_LENGTH
=
3
AUTOCOMPLETE_MIN_SIMILARITY
=
0.1
```
4.
If you want to use rest_framework for querying words, include the URLconf in your project urls.py like this:
```
py
path
(
'
api/
'
,
include
(
'
autocomplete_multi_models.expose_with.rest_framework.urls
'
)),
```
5.
If you want to use graphene for querying words, Inherite the Query in your project schema.py like this:
```
py
class
Query
(
my_app
.
schema
.
Query
,
autocomplete_multi_models
.
expose_with
.
graphene
.
schema
.
FindClosestWordsQuery
,
graphene
.
ObjectType
,
):
debug
=
graphene
.
Field
(
DjangoDebug
,
name
=
"
_debug
"
)
```
6.
To build the index, run the following commande. It is recommended to run it daily
```
sh
python manager.py makeautocompleteindex
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment