74👍
✅
You can make Query string using GET parameters like this
request.GET.urlencode()
This does not include the ?
prefix, and it may not return the keys in the same order as in the original request.
64👍
Third option:
>>> from urlparse import urlparse, parse_qs
>>> url = 'http://something.com?blah=1&x=2'
>>> urlparse(url).query
'blah=1&x=2'
>>> parse_qs(urlparse(url).query)
{'blah': ['1'], 'x': ['2']}
In Python 3+ this is available as:
from urllib.parse import parse_qs
- [Django]-The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting
- [Django]-Django 2, python 3.4 cannot decode urlsafe_base64_decode(uidb64)
- [Django]-Django – Site matching query does not exist
59👍
I prefer using
request.META['QUERY_STRING']
From docs:
https://docs.djangoproject.com/en/stable/ref/request-response/#django.http.HttpRequest.META
This does not include the ?
prefix.
- [Django]-How to get form fields' id in Django
- [Django]-Vagrant + Chef: Error in provision "Shared folders that Chef requires are missing on the virtual machine."
- [Django]-Django @login_required decorator for a superuser
Source:stackexchange.com