Hey all,

Thanks for reading. I have gone over and over the section first half
of the chapter about having a simple search form. Here are my views:

from django.shortcuts import render_to_response
from mysite.books.models import Book

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('Enter a search term.')
        elif len(q) > 20:
            errors.append('Please enter at most 20 characters,
dumbass.')
        else:
            books = Book.objects.filter(title_icontains=q)
            return render_to_response('search_results.html',
                {'books': books, 'query': q})
    return render_to_response('search_form.html', {'errors': errors})

The error part of the view works fine, but when I get to the 'else'
clause I always get this error:

cannot resolve keyword 'title_icontains' into field. Choices are:
authors, id, publication_date, publisher, title

Can anyone enlighten me. I'm new to programming, so I'm sure it's just
a stupid mistake, but I can't see it. Thanks.

~Lee


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to