A Django template tag to modify url's query string.
Project description
A Django template tag to modify url’s query string.
Documentation
The full documentation is at https://django-url-templatetag.readthedocs.org.
Quick Start
Install Django QUrl Template Tag:
pip install django-qurl-templatetag
After installation is done, add qurl_templatetag to the INSTALLED_APPS setting in your settings.py file:
INSTALLED_APPS = ( # … 'qurl_templatetag', # … )
Tag Usage
{% load qurl %} {% qurl url [param]* [as <var_name>] %} Parameters: name=value: replace all values of name by one value name=None: remove all values of name name+=value: append a new value for name name-=value: remove the value of name with the value name++: increment the value by one name--: decrement the value by one Example: {% qurl '/search?page=1&color=blue&color=green' order='name' page=None color+='red' color-='green' %} Output: /search?color=blue&order=name&color=red {% qurl request.get_full_path order='name' %}
Library Usage
A Qurl object has a set of chainable methods to modify the querystring parameters.
Available methods are:
- set: replace all values of name by one value, parameter is removed when value is None
- add: append a new value for name
- remove: remove the value of name with the value
- inc: increment the value by another value (optional, defaults to 1)
- dec: decrement the value by another value (optional, defaults to 1)
- get: build the url
from qurl_templatetag import Qurl >>> Qurl('http://www.sophilabs.co/?page=1&tags=python')\ .inc('page', value=2)\ .add('tags', 'django')\ .add('tags', 'web')\ .remove('tags', 'python')\ .get() http://www.sophilabs.co/?page=3&tags=django&tags=web
Tests
$ pip install -r requirements/test.pip $ python runtests.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size django-qurl-templatetag-0.0.14.tar.gz (13.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for django-qurl-templatetag-0.0.14.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bba09228bde037659ae678f8c69438156e0ee71c297ae219979804187eef9025 |
|
MD5 | 27284e74a8e6d5633b78608a18361857 |
|
BLAKE2-256 | b7ce12d548e042c6cbb89839061cc382bd668e28f552aed9f94bc7f263dc6499 |