Haystack ( ) , , . , , " ", - (, whoosh, solr ..) .
, , , "SearchIndexes" . "" "" + "", .
, API SearchQuerySet, , , . models, , .
, , , "", , "" "" ( ). ( ).
:
/search/?q=python&content=proposal
/search/?q=python&content=everything
, :
from proposals.models import Proposal
from comments.models import Comment
def search(request):
if request.method == "GET":
if "q" in request.GET:
query = str(request.GET.get("q"))
content_type = request.GET.get("content")
search_models = []
if content_type is "proposal":
search_models = [Proposal]
elif content_type is "everything":
search_models = [Proposal, Comment]
results = SearchQuerySet().all().filter(content=query).models(*search_models)
return render(request, "search/search.html", {"results": results})
( ), , get_model django.db .