Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Absolute URI functions and template tags for Django

Project Description


Absolute URI functions and template tags for Django.


There are times when you need to output an absolute URL (for example, inside an email), but you don’t always have access to the request. These utilities use the Sites Framework if available in order to create absolute URIs.


Install django-absoluteuri:

pip install django-absoluteuri

Then add it to your INSTALLED_APPS:

    # ...

django-absoluteuri requires the Sites Framework to be in INSTALLED_APPS well and configured as well.


The protocol of the uris returned by this library defaults to http. You can specify the protocol with the ABSOLUTEURI_PROTOCOL setting.


# Elsewhere
>>> absoluteuri.build_absolute_uri('/some/path/')

Template Tags

There are two template tags, absoluteuri and absolutize. absoluteuri works just like the url tag, but that it outputs absolute URLs.

{% load absoluteuri %}

<a href="{% absoluteuri 'my_view' kwarg1='foo' kwarg2='bar' %}">click here</a>

absolutize will take a relative URL and return an absolute URL.

{% load absoluteuri %}

<a href="{% absolutize url_from_context %}">click here</a>


Sometimes instead of template tags, it’s easier to use filters. You can do that as well.

{% load absoluteuri %}

<a href="{{ my_object.get_absolute_url|absolutize }}">click here</a>

But there are situations where tag can not be used but filter can.

{% load absoluteuri %}

{% include "some-other-template.html" with url=my_object.get_absolute_url|absolutize %}


There are also two functions that django-absoluteuri provides, build_absolute_uri and reverse, which are equivalents of request.build_absolute_url and urlresolvers.reverse.

>>> import absoluteuri

>>> my_relative_url = '/path/to/somewhere/'
>>> absoluteuri.build_absolute_uri(my_relative_url)
>>> absoluteuri.reverse('viewname', kwargs={'foo': 'bar'})


1.2.0 (2016-02-29)

  • Add absolutize filter. This deprecates the absolutize tag. [#4]

1.1.0 (2015-03-23)

  • Added ABSOLUTEURI_PROTOCOL settings. [#1]
  • Documented sites framework requirement.

1.0.0 (2015-03-17)

  • First release on PyPI.
Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-absoluteuri-1.2.0.tar.gz (7.9 kB) Copy SHA256 Checksum SHA256 Source Feb 29, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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