Commits

Jakub Zalewski committed 3417b89

redirect_to_url shortcut

  • Participants
  • Parent commits 16939ec

Comments (0)

Files changed (1)

File annoying/shortcuts.py

+from django.core.urlresolvers import reverse
+from django.http import HttpResponseRedirect
+import urllib
+
+
+def redirect_to_url(named_url, *args, **kwargs):
+    url = reverse(named_url, args=list(args))
+    if kwargs:
+        url += '?' + urllib.urlencode(kwargs)
+    return HttpResponseRedirect(url)