#30038: New shortcut: redirect_with_params()
---------------------------------------------+------------------------
               Reporter:  agustin bacigalup  |          Owner:  nobody
                   Type:  New feature        |         Status:  new
              Component:  Uncategorized      |        Version:  2.1
               Severity:  Normal             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 I'd like to contribute to Django by adding a shorcut, similar to
 `django.shortcuts.redirect` but also appends request's GET parameters. I
 found myself using it a lot, and I wonder if it's useful for the
 community. If so, should I fork Django on Github and submit a pull
 request?

 {{{
 def redirect_with_params(request, to, *args, **kwargs):
     """
     Same as `django.shortcuts.redirect` but recieves a `request` as first
 parameter.
     """
     response = redirect(to, *args, **kwargs)
     url = response.url
     params = request.GET.urlencode()
     if params:
         url = "%s?%s" % (response.url, params)
     return response.__class__(url)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30038>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.209305bc09082c8f40fb51b76f1eaff2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to