aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework
diff options
context:
space:
mode:
Diffstat (limited to 'djangorestframework')
-rw-r--r--djangorestframework/templatetags/add_query_param.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/djangorestframework/templatetags/add_query_param.py b/djangorestframework/templatetags/add_query_param.py
index 4cf0133b..044f543b 100644
--- a/djangorestframework/templatetags/add_query_param.py
+++ b/djangorestframework/templatetags/add_query_param.py
@@ -1,10 +1,20 @@
+from django.http import QueryDict
from django.template import Library
-from urlobject import URLObject
+from urlparse import urlparse, urlunparse
register = Library()
+def replace_query_param(url, key, val):
+ (scheme, netloc, path, params, query, fragment) = urlparse(url)
+ query_dict = QueryDict(query).copy()
+ query_dict[key] = val
+ query = query_dict.urlencode()
+ return urlunparse((scheme, netloc, path, params, query, fragment))
+
+
def add_query_param(url, param):
- return unicode(URLObject(url).with_query(param))
+ key, val = param.split('=')
+ return replace_query_param(url, key, val)
register.filter('add_query_param', add_query_param)