I'm trying to make a search engine with my database, parsing de text that the user write in the textbox to make a list with the cleaned words, in just one table of the DB in the fields: title, descripcion and tags, I have something like this but I don't know how to finish it:
from django.http import HttpResponse from django.shortcuts import render_to_response from myproject.parsing.models import Stores from pyparsing import * from django.db.models import Q def search_form(request): return render_to_response('search_form.html') def search(request): errors= [] if 'q' in request.GET: q = request.GET['q'] if not q: errors.append('Write something') else: qclean= parseText(q) for Word in qclean: Foundstores = Stores.objects.filter(Q(name__icontains=Word) | Q(description__icontains=Word) | Q(tags__icontains=Word)) #But remeber that I have more than one word, so I need to concatenate all the querysets of each one of the words in qclean return render_to_response('search_results.html', {'Found': Foundstores, 'query': qclean}) return render_to_response('search_form.html', {'errors': errors}) def parseText(texto): parser=OneOrMore(Word(alphas)) #articles in spanish arreglo=("de","en","la") for articulo in arreglo: parser.ignore(CaselessLiteral(articulo)) salida=parser.parseString(texto) return salida -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.