从Django在Algolia中存储对象

时间:2019-01-20 19:16:38

标签: python django algolia

我刚开始使用Algolia和Django,它似乎相对容易设置和定义。用户示例:

const shopLists = [
  { genre: 'aaa', image: AAA},
  { genre: 'bb' , image: BBB},
  { genre: 'ccc', image: CCC},
  { genre: 'ddddd', image: DDD}
]

//
<Text style={ styles.shopListsGenre }>
  {shopLists.genre}
</Text>

///

//I would like to apply 33% padding to aaa and ccc genre and apply
  other padding to others.

const styles = StyleSheet.create({
 shopListsGenre: {
  paddingLeft: '33%'
 },
})

除了当我添加与其他字段具有关联性的字段时事情开始中断之外

from algoliasearch_django import AlgoliaIndex
from algoliasearch_django.decorators import register

from .models import User

@register(User)
class UserIndex(AlgoliaIndex):

    fields = ("id",'first_name', 'last_name', 'email', ''city', "state","zip_code", "phone_number")
    settings = {'searchableAttributes': ['first_name', 'last_name', 'email']}
    index_name = 'user_index'

工作和朋友都有自己的模型和数据透视表,而我经常会遇到诸如

的错误
fields = ("id",'first_name', 'last_name', 'email', ''city', "state","zip_code", "phone_number", 
"jobs", "friends")

在Algolia中正确存储数组或相关值有哪些技巧,并且采用“ Django”方式进行?

0 个答案:

没有答案