query parameters for search

0 views
Skip to first unread message

Jiri Barton

unread,
Jun 4, 2007, 12:30:47 PM6/4/07
to Django users
What is the best way of adding query parameters (aka GET parameters)
to a URL?

return HttpRedirect(reverse('animal-search') + '?q=%s&page=%d' %
(animal.name, current_page))

seems awkward to me (not to mention escaping the name). How can I
avoid creating query parameters manually? Or, should I avoid query
parameters altogether? It seems every page is using query parameters
in searches.

And how should I create such URLs from within templates?

Thank you,
Jiri

Joseph Heck

unread,
Jun 4, 2007, 12:45:26 PM6/4/07
to django...@googlegroups.com
While it may look ugly, it's actually pretty effective - depending on
what you want to enable with search queries overlaid on URL's. If you
only had simple (i.e. one word) terms, you could write the query into
the URL itself, but I found that using a url like /search/ and then
appending on ?q=... and page=... was really about the most expedient
path.

-joe

Reply all
Reply to author
Forward
0 new messages