You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
936 B
34 lines
936 B
from haystack import indexes
|
|
from models import PlaceConference
|
|
|
|
|
|
class PlaceExpositionIndex(indexes.SearchIndex, indexes.Indexable):
|
|
text = indexes.CharField(document=True, use_template=True)
|
|
where = indexes.MultiValueField()
|
|
|
|
country = indexes.CharField(model_attr='country', null=True)
|
|
city = indexes.CharField(model_attr='city', null=True)
|
|
|
|
def prepare_country(self, obj):
|
|
if obj.country:
|
|
return '%s'%obj.country_id
|
|
return ''
|
|
|
|
def prepare_city(self, obj):
|
|
if obj.city:
|
|
return '%s'%obj.city_id
|
|
return ''
|
|
|
|
def prepare_where(self, obj):
|
|
country = [tr.name for tr in obj.country.translations.all()]
|
|
city = [tr.name for tr in obj.city.translations.all()]
|
|
|
|
return country + city
|
|
|
|
def get_model(self):
|
|
return PlaceConference
|
|
|
|
def index_queryset(self, using=None):
|
|
|
|
return self.get_model().objects.filter()
|
|
|
|
|