Skip to main content

Absolute URLs tools for django

Project description

Django Absolute provides context processors and template tags to use full absolute URLs in templates.

Installation

You can install Django Absolute with pip:

pip install django-absolute

or with easy_install:

easy_install django-absolute

Add absolute to your settings.INSTALLED_APPS.

Context processor

Add absolute.context_processors.absolute to your settings.TEMPLATE_CONTEXT_PROCESSORS. Django Absolute context processor depends on request context processor:

from django.conf import global_settings

TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
    'django.core.context_processors.request',
    'absolute.context_processors.absolute',
)

Then you can access the following variables in your templates:

  • ABSOLUTE_ROOT: full absolute root URL (without trailing slash) based on incoming request

  • ABSOLUTE_ROOT_URL: full absolute root URL (with trailing slash) based on incoming request

  • SITE_ROOT: full absolute root URL (without trailing slash) based on current Django Site

  • SITE_ROOT_URL: full absolute root URL (with trailing slash) based on current Django site

Template tags

Django absolute provide 2 template tags:

  • absolute: acts like url but provide a full URL based on incoming request.

  • site: acts like url but provide a full URL based on current Django Site.

To use theses template tags, you need to load the absolute template tag library.:

{% url index %}

{% load absolute %}
{% absolute index %}
{% site index %}

These template tags have exactly the same syntax as url.

Project details


Download files

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

Source Distribution

django-absolute-0.1.tar.gz (6.2 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-absolute-0.1.tar.gz
Algorithm Hash digest
SHA256 1ca930e1cb0950e736e9e934503e3430f583eec24bbf19e3ad7541677d8e9001
MD5 a3fcbd4afd2fd9ba8339725e040f3ce8
BLAKE2b-256 934b47fb4b5621fec2253d049c2be29f4381d3feb02550545da6b843f02afefd

See more details on using hashes here.

Provenance

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