Commits

Jakub Zalewski committed 3417b89

redirect_to_url shortcut

Comments (0)

Files changed (1)

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)