[EMAIL PROTECTED] wrote:

> all code came from here:
> http://djangobook.com/en/1.0/chapter07/

> in my view:
> def search(request):
>     query = request.GET.get('q', '')
>     if query:
>         qset = (
>             Q(title__icontains=query) |
>             Q(forum__title__icontains=query) |
>             Q(color__icontains=query)
>         )
>         results = Thread.objects.filter(qset).distinct()
>     else:
>         results = []
> 
>       return render_to_response("groups/search.html", {
>         "results": results,
>         "query": query
>         })

indentation matters in Python.

for the above code to work, the return statement should be aligned with 
the "if" statement, not the "results = []"

judging from your post, you've used spaces for some of the indents and 
4-space tabs for others.  the python interpreter does allow tabs for 
indentation, but assumes that they have the standard size (8 spaces).  I 
suggest configuring your editor to prevent it from inserting tabs, or at 
least configuring it to use 8-space tabs.

(and if your editor doesn't allow you to configure indentation size 
independently from tab size, get a better editor...)

</F>


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to