O'Reilly logo

Django 1.0 Web Site Development by Ayman Hourieh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Advanced searching

In Chapter 6, we built a simple search feature into our project. We did so to learn more about AJAX and live form processing. The search page returns bookmarks that contain the query string in the title and it is implemented using the filter method of the model API. This line of code does the actual searching in our search view:

bookmarks = Bookmark.objects.filter(title__icontains=query)

This was sufficient to get a basic search page working. However, things are not this simple in reality. To see why, let's say that a user entered "AJAX advantages" into the search box. If the database contains a bookmark with the string "AJAX advantages" in its title, it will be returned in the search results. However, if there is a bookmark titled ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required