Created
October 15, 2016 06:35
-
-
Save bluethon/4b14ee0c4590b3ef3a099f6e33b96285 to your computer and use it in GitHub Desktop.
urlencode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import QueryDict | |
def url_with_querystring(path, query_dict): | |
""" URL查询参数拼接 """ | |
qdict = QueryDict('', mutable=True) | |
qdict.update(query_dict) | |
return path + '?' + qdict.urlencode() | |
url_dict = { | |
'course': course, | |
'term_id': term_id, | |
'item': str(item), | |
'info': str(info_id) | |
} | |
url = url_with_querystring(reverse('order:invoice_pay_confirm'), url_dict) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib.parse import urlencode | |
def url_with_querystring(path, query_dict): | |
""" URL查询参数拼接 """ | |
return path + '?' + urlencode(query_dict) | |
url_dict = { | |
'course': course, | |
'term_id': term_id, | |
'item': str(item), | |
'info': str(info_id) | |
} | |
url = url_with_querystring(reverse('order:invoice_pay_confirm'), url_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment