Opened 6 years ago

Last modified 6 years ago

#30038 closed New feature

New shortcut: redirect_with_params() — at Initial Version

Reported by: agustin bacigalup Owned by: nobody
Component: Uncategorized Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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)

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top