mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 19:43:59 +03:00
Merge branch 'master' of git://github.com/flisky/django-rest-framework into flisky-master
This commit is contained in:
commit
9d281e187a
|
@ -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
|
||||
|
|
18
rest_framework/tests/test_templatetags.py
Normal file
18
rest_framework/tests/test_templatetags.py
Normal file
|
@ -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",
|
||||
])
|
Loading…
Reference in New Issue
Block a user