angular.module('app', []).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
class Article(models.Model):
...
case = models.ForeignKey(Case, related_name='articles')
...
class CaseSerializer(serializers.ModelSerializer):
class Meta:
model = Case
fields = (..., ..., 'articles')
from collections import defaultdict
from haystack.forms import FacetedSearchForm
class FacetedNotEmptySearchForm(FacetedSearchForm):
def no_query_found(self):
return self.searchqueryset.all()
@property
def selected_multi_facets(self):
selected_multi_facets = defaultdict(list)
for facet_kv in self.selected_facets:
if ":" not in facet_kv:
continue
field_name, value = facet_kv.split(':', 1)
selected_multi_facets[field_name].append(value)
return selected_multi_facets
def search(self):
sqs = super(FacetedSearchForm, self).search()
for field, values in self.selected_multi_facets.items():
if not values:
continue
clean_values = ['"%s"' % sqs.query.clean(val) for val in values]
sqs = sqs.narrow(u'%s:(%s)' % (field, " OR ".join(clean_values)))
return sqs