I have the following view set up: def concord(request): searchterm = request.GET['q'] ... more stuff ... return render_to_response('concord.html', locals())
With URL "http://mysite.com/concord/?q=برشه", and template code <p>Your search for {{ searchterm }} returned {{ results }} results in {{ texts.count }} texts.</p> I get this result on the page: Your search for برشه returned 0 results in 8 texts. The search term (برشه) is being passed successfully, but there should be 13 results, not zero. When I hard-code "searchterm = 'برشه' " into the concord view, instead of "searchterm = request.GET['q']", the page displays perfectly. The full code for the view is below... What am I missing here? ~Karen def concord(request): searchterm = request.GET['q'] #== Retrieving relevant corpus texts from database === texts = Text.objects.filter(content__contains=searchterm) content = "" for t in texts: content += t.content + "\n" #== Encoding === content_uni = content.encode('utf-8') tokens = content_uni.split() #== Concordancing with NLTK === text = nltk.Text(tokens) ci = nltk.text.ConcordanceIndex(text.tokens) offsets = ci.offsets(searchterm) results = len(offsets) tokens = ci.tokens() #== Set variables to return to webpage === context = [] for offset in offsets: before = ' '.join(tokens[offset-10:offset]) word = tokens[offset] after = ' '.join(tokens[offset+1:offset+10]) context.append([before, word, after]) return render_to_response('concord.html', locals()) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.