I am trying to reproduce the admin search functionality tell me what
you think and how I can 1) fix it because it isn't working 2) improve
it.

Here is my view:
keywords = request.GET['keyword'].split()
sql = ""
first = True
for word in keywords:
    if first:
        sql += "(title LIKE '%" + word + "%' OR description LIKE '%" +
word + "%')"
        first = False
    else:
        sql += " AND (title LIKE '%" + word + "%' OR description LIKE
'%" + word + "%')"

results_list = Resource.objects.extra(where=[sql])

return render_to_response('tick/base_results.html', {'results_list':
results_list})

Any ideas?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to