mirror of
https://github.com/magnum-opus-tender-hack/backend.git
synced 2024-11-25 10:43:44 +03:00
autcomplete
This commit is contained in:
parent
da2b9e16d4
commit
ed2a60b481
|
@ -1,6 +1,6 @@
|
|||
from typing import List, Dict
|
||||
|
||||
from search.models import Product, Category, Characteristic
|
||||
from search.models import Product, Category, Characteristic, UnitCharacteristic
|
||||
|
||||
|
||||
def autocomplete_schema(val: str, exclude: List[Dict]):
|
||||
|
@ -46,4 +46,15 @@ def autocomplete_schema(val: str, exclude: List[Dict]):
|
|||
].values("name", "value")
|
||||
]
|
||||
)
|
||||
schema.extend(
|
||||
[
|
||||
{
|
||||
"coordinate": char["value"].lower().index(val.lower()),
|
||||
"value": {
|
||||
"type": char["name"] + "_numeric",
|
||||
"value": char["value"]
|
||||
}
|
||||
} for char in UnitCharacteristic.objects.filter(value__unaccent__icontains=val)[:20].values("name", "value")
|
||||
]
|
||||
)
|
||||
return schema
|
||||
|
|
Loading…
Reference in New Issue
Block a user