Oto Brglez wrote:
> Hi all you coders outthere!
> 
> I want to search for data in my database. Thats all fine.
> I just need help with quetys in urls...
> 
> I want to have link like this:
> /search/q=cars
> /search/q=car+red+blue
> /search/q=my+search+query
> 
> The problem is that i don't know what to write inside urls.py.
> What should i write in urls so that its passed to view as plain text?

Your urls.py should just have "^/search/$" as the URL.  The 
resulting view function should then make use of the request.GET 
dictionary'ish object:

   def search_view(request):
     terms = [
       term.strip()
       for term in request.GET.get("q", "").split()
       if term.strip()
       ]
     if terms:
       return render_search_results(request, terms)
     else:
       return no_search_string_passed(request)

-tim




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