aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2013-12-23 10:47:20 +0000
committerTom Christie2013-12-23 10:47:20 +0000
commit9d281e187a296df168c429bb5753150eaedfa487 (patch)
treee877e42fb0ddc64434e7ddac823f2875e4419a61 /rest_framework
parentd8a95b4b6d4480089d38808b45a7b47f30e81cdd (diff)
parent80e9f0d64b0ace50d413eaccbf28a3b4ded75ed3 (diff)
downloaddjango-rest-framework-9d281e187a296df168c429bb5753150eaedfa487.tar.bz2
Merge branch 'master' of git://github.com/flisky/django-rest-framework into flisky-master
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/templatetags/rest_framework.py2
-rw-r--r--rest_framework/tests/test_templatetags.py18
2 files changed, 19 insertions, 1 deletions
diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py
index e9c1cdd5..5c267ab3 100644
--- a/rest_framework/templatetags/rest_framework.py
+++ b/rest_framework/templatetags/rest_framework.py
@@ -144,7 +144,7 @@ def add_query_param(request, key, val):
"""
Add a query parameter to the current request url, and return the new url.
"""
- return replace_query_param(request.get_full_path(), key, val)
+ return replace_query_param(request.build_absolute_uri(), key, val)
@register.filter
diff --git a/rest_framework/tests/test_templatetags.py b/rest_framework/tests/test_templatetags.py
new file mode 100644
index 00000000..cbac768a
--- /dev/null
+++ b/rest_framework/tests/test_templatetags.py
@@ -0,0 +1,18 @@
+# encoding: utf-8
+from __future__ import unicode_literals
+from django.test import TestCase
+from rest_framework.test import APIRequestFactory
+from rest_framework.templatetags.rest_framework import add_query_param
+
+factory = APIRequestFactory()
+
+
+class TemplateTagTests(TestCase):
+
+ def test_add_query_param_with_non_latin_charactor(self):
+ request = factory.get("/?q=查询")
+ json_url = add_query_param(request, "format", "json")
+ self.assertIn(json_url, [
+ "http://testserver/?format=json&q=%E6%9F%A5%E8%AF%A2",
+ "http://testserver/?q=%E6%9F%A5%E8%AF%A2&format=json",
+ ])