diff options
| author | Tom Christie | 2012-01-11 13:50:43 +0000 |
|---|---|---|
| committer | Tom Christie | 2012-01-11 13:50:43 +0000 |
| commit | 97c5262e9ca318d0ff62d44a1f2d3ea31120d282 (patch) | |
| tree | 37f1376ee5e9ff2cbb63dd59bf0452dba6edfac6 /djangorestframework | |
| parent | c8134a6340b342b617022186da7d79e9e9eb755c (diff) | |
| download | django-rest-framework-97c5262e9ca318d0ff62d44a1f2d3ea31120d282.tar.bz2 | |
Refactor add_query_param to use URLObject. Refs #112.
Diffstat (limited to 'djangorestframework')
| -rw-r--r-- | djangorestframework/templatetags/add_query_param.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/djangorestframework/templatetags/add_query_param.py b/djangorestframework/templatetags/add_query_param.py index 94833bce..ce175b81 100644 --- a/djangorestframework/templatetags/add_query_param.py +++ b/djangorestframework/templatetags/add_query_param.py @@ -1,17 +1,11 @@ from django.template import Library -from urlparse import urlparse, urlunparse -from urllib import quote +from urlobject import URLObject register = Library() + def add_query_param(url, param): (key, sep, val) = param.partition('=') - param = '%s=%s' % (key, quote(val)) - (scheme, netloc, path, params, query, fragment) = urlparse(url) - if query: - query += "&" + param - else: - query = param - return urlunparse((scheme, netloc, path, params, query, fragment)) + return unicode(URLObject(url) & (key, val)) register.filter('add_query_param', add_query_param) |
