我正在尝试索引具有一对多(外键)关系的模型。而且我无法处理如何为此声明 search_indexes.py,任何人都知道该怎么做:
模型.py:
class CarModel(models.Model):
manufacturer = models.ForeignKey(Manufacturer)
class Manufacturer(models.Model):
name = models.CharField(max_length=200)
search_indexes.py:
class ManufacturerIndex(indexes.SearchIndex, indexes.Indexable):
carmodel = MultiValueField(indexed=True, stored=True, faceted=True)
def prepare_carmodel(self, obj):
return ???????????????????
def get_model(self):
return Manufacturer