This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Append, remove or replace query string parameters from a url (preserve order). Originally created by Sophilabs - https://github.com/sophilabs/django-qurl-templatetag

Installation

pip install -e git+https://github.com/obiwanus/django-qurl.git#egg=django-qurl

Usage in templates

Example:

{% load qurl %}

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

{% qurl request.get_full_path order='name' %}
Output: /your/current/path/?order=name

Parameters:

name=value: replace all values of name by one value
name--: remove all values of name
name+=value: append a new value for name
name-=value: remove the value of name with the value

Using reverse in the template tag:

{% qurl 'url_name' [reverse_params] | order=name color+=red color+=green %}
Output: /reversed/url/?order=name&color=red&color=green

The reverse syntax is exactly the same as in the standard Django {% url %} tag.

Usage in views

Examples:

from qurl import qurl

url = '/testurl/1/'
qurl(url, add={'a': 'a1', 'b': ['b1', 'b2']})
# Output: /testurl/1/?a=a1&b=b1&b=b2

url = '/testurl/1/?a=a1&b=b1&b=b2'
qurl(url, add={'a': 'a2'}, remove=['b'])
# Output: /testurl/1/?a=a2

url = '/testurl/1/?a=a1&b=b1&b=b2'
qurl(url, add={'a': ['a2']}, remove=['b'])
# Output: /testurl/1/?a=a1&a=a2

url = '/testurl/1/?a=a1&b=b1&b=b2'
qurl(url, exclude={'b': 'b2'}, add={'a': 'a2'})
# Output: /testurl/1/?a=a1&a=a2&b=b1

# You can use request.GET as a base
url = '/testurl/1/'
qurl(url, add=request.GET, exclude={'b': 'b1'}

Notes:

If you want to assign a specific value to the parameter (replacing all existing values), use add={'param': 'value'}.

If you want to add a value to already existing ones, use add={'param': ['value']}. You can add more than one value of course.

Please check the tests for more usage examples.

Running tests

Please make sure tox is installed and run tox from the command line.

The source code is hosted on Github: https://github.com/obiwanus/django-qurl/

Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-qurl-0.1.1.tar.gz (3.8 kB) Copy SHA256 Checksum SHA256 Source Feb 9, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting