Composing an URL using the current search query

4 views
Skip to first unread message

Filipe Correia

unread,
Aug 2, 2007, 7:20:17 AM8/2/07
to Django users
Hi,

I'm struggling with an issue similar to the one presented on this
thread:
http://groups.google.com/group/django-users/browse_frm/thread/536c0a7ba9f8c155/5d61867c4339e4d8

In a view, getting the various elements that compose the current URL's
query string is easy, one only needs to use the "request" object:

request.GET['name']

however, in my case I would like to preserve the current querystring,
whichever it is, replacing (or adding) only the value for a certain
variable (say, the value for "page"). So I would be reading the parsed
query string only to compose it again with very little change.

Is there a more elegant way to do this?

thanks in advance,
Filipe Correia

Filipe Correia

unread,
Aug 7, 2007, 2:17:02 PM8/7/07
to Django users
I think an example may illustrate what I mean a little better.

Having a view with an url like the following:
http://domain.com/objects/123/rels/?name=zyx&type=xyz

Considering this same view produces hyperlinks (to be sent to it's
template) that add extra query parameters to it's URL, like for
example:
http://domain.com/objects/123/rels/?name=zyx&type=xyz&page=2

Is there a simpler way to achieve this than reading the parsed
parameters from the "request" object, reconstructing the original URL,
and finally adding the extra parameter?

thanks,
Filipe


On Aug 2, 12:20 pm, Filipe Correia <fcorr...@gmail.com> wrote:
> Hi,
>
> I'm struggling with an issue similar to the one presented on this

> thread:http://groups.google.com/group/django-users/browse_frm/thread/536c0a7...

Reply all
Reply to author
Forward
0 new messages