urlutils — Utilities for working with URLs¶
-
create_querydict(querystringargs, initial_query_string=None, ignore_none_values=True)¶ Parameters: - querystringargs (dict) – The querystring args to add/replace.
- initial_query_string (str) – The initial querystring. Any ovelapping
keys between this and
querystringargsis overridden by the value inquerystringargs. - ignore_none_values (bool) – If this is
True(default), we ignoreNonevalues inquerystringargs.
Returns: The created
django.http.request.QueryDict.
-
update_querystring(url, querystringargs, ignore_none_values=True)¶ Update the querystring portion of the given
url.Parameters: Returns: The updated url.
Examples
Add querystring argument:
from django_cradmin import urlutils urlutils.update_querystring('http://example.com', {'search': 'test'})
Update querystring argument:
urlutils.update_querystring('http://example.com?search=something&page=2', {'search': 'updated'})