On 2 jan, 15:25, Filipe Correia <[email protected]> wrote:
> Hi all,
>
> I'm using a generic view to redirect from one URL to another:
>
> urlpatterns += patterns('prj.app.views',
> (r'^foo/(?P<tail>.*)$', redirect_to, {'url': '/foo/bar/%(tail)s'}),
> )
>
> However, the URLs I want to redirect actually look like this:
>
> http://localhost/foo/?param1=value1¶m2=value2
The url dispatch is made on the request "path" component, which
doesn't include GET params.
> This means that when redirecting the GET parameters will be lost,
> which is not my intent.
>
> Is there any way to maintain GET parameters with the "redirect_to"
> generic view? Or will I have to implement my own view?
The second. But this shouldn't be that hard:
# NB : Q&D, not tested
def my_redirect_to(request, url):
qs = request.META.QUERY_STRING
if qs:
url = "%s?%s" % (url, qs)
return redirect_to(url)
HTH
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---