Skip to main content

django-urltags contains several template tags and filters for messing with URLs

Project description

Django URLtags is a collection of template tags and filters for manipulating URLs or adding some convenience methods for common practices.

add_qs_param

Usage: {% add_qs_param url varname value %}

This tag intelligently adds or replaces the query string parameter varname and assigns it value.

url, varname, and value can be static values or variables

Examples

Adding a single query string parameter

{% add_qs_param http://example.com/ q 1 %}

generates:

http://example.com/?q=1

Adding a query string parameter to a URL with a query string.

{% add_qs_param http://example.com/?sort=asc q 1 %}

generates:

http://example.com/?sort=asc&q=1

Adding a query string parameter to a URL that already has that parameter.

{% add_qs_param http://example.com/?q=5 q 1 %}

generates:

http://example.com/?q=1

Adding a query string parameter to a URL that has a page fragment.

{% add_qs_param http://example.com/#gohere q 1 %}

generates:

http://example.com/?q=1#gohere

add_fragment

Usage: {{ url|add_fragment:variable }} or {{ url|add_fragment:"fragment" }}

This tag intelligently adds or replaces the URL fragment. You can pass a variable as the parameter to add_fragment or a static value. You must quote static values.

Example

{{ url|add_fragment:"gohere" }}

generates:

http://example.com/#gohere

absurl

Just like Django’s url tag but adds the domain of the current site.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-urltags-0.1.tar.gz (542.8 kB view details)

Uploaded Source

File details

Details for the file django-urltags-0.1.tar.gz.

File metadata

File hashes

Hashes for django-urltags-0.1.tar.gz
Algorithm Hash digest
SHA256 ae827278fb421645264b88118e643b68fe43b6d902e3eb6f232779e21ea46bb7
MD5 6fcef74b15d8d37501260d4f45632181
BLAKE2b-256 118ee600a47a20629ec2a7bb6772bb0704afec7d851237782e9298b496924dbc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page