nephila/dev/: django-qurl-templatetag-0.0.13.post1 metadata and description

Homepage | Simple index

A Django template tag to modify url's query string.

author Sophilabs
author_email hi@sophilabs.com
classifiers
  • Development Status :: 2 - Pre-Alpha
  • Intended Audience :: Developers
  • License :: OSI Approved :: MIT License
  • Natural Language :: English
  • Programming Language :: Python :: 2
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.3
  • Programming Language :: Python :: 3.4
  • Programming Language :: Python :: 3.5
keywords templatetag
license MIT license
platform
  • UNKNOWN
File Tox results History
django-qurl-templatetag-0.0.13.post1.tar.gz
Size
15 KB
Type
Source
django_qurl_templatetag-0.0.13.post1-py2.py3-none-any.whl
Size
7 KB
Type
Python Wheel
Python
2.7

Django QUrl Template Tag

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~=value: remove the value string from each value of name
        name++: increment the value by one
        name--: decrement the value by one

Example:

    {% qurl '/search?page=1&color=blue&color=green&q=some+thing' order='name' page=None color+='red' color-='green' q~='some' %}
    Output: /search?color=blue&order=name&color=red&q=thing

    {% 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
  • replace: 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')\
        .add('q', 'some+thing')\
        .replace('q', 'some')\
        .get()
http://www.sophilabs.co/?page=3&tags=django&tags=web&q=thing

Tests

$ pip install -r requirements/test.pip
$ python runtests.py

About

Django Qurl Template Tag is maintained and funded by sophilabs, inc. The names and logos for sophilabs are trademarks of sophilabs, inc.

History

0.0.3 (2016-11-14)

  • Third release on PyPI.

0.0.2 (2016-09-29)

  • Second release on PyPI.

0.0.1 (2013-11-14)

  • First release on PyPI.