Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is possible to add GET variables in a redirect ? (Without having to modifiy my urls.py)

If I do redirect('url-name', x)

I get HttpResponseRedirect('/my_long_url/%s/', x)

I don't have complains using HttpResponseRedirect('/my_long_url/%s/?q=something', x) instead, but just wondering...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
764 views
Welcome To Ask or Share your Answers For Others

1 Answer

Since redirect just returns an HttpResponseRedirect object, you could just alter that:

response = redirect('url-name', x)
response['Location'] += '?your=querystring'
return response

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...