Skip to main content

This is an implementation of rev=canonical url shortening in the form of Django application. Basically rev=canonical is nice idea about that site should give you two links to actual page: one is human-readable, and another is short version, intented to use in limited conditions.

This implementation is modelled after Simon Willison’s post and returns 301 permanent redirect for your short urls.

Configuration

Installation is simple - use it like any another Django application, basically: put it where other application of your project are residing and add 'revcanonical' to INSTALLED_APPS in settings.py. Then edit your urls.py and add inclusion of revcanonical’s urls to urlpatterns:

url(r'', include('revcanonical.urls')),

Use r'^someprefix/' instead of first argument if you’d like to see prefixed urls.

By default revcanonical uses internal Django’s Site model to determine your site domain, but you can set it manually in settings.py as REVCANONICAL_SITE variable.

Usage

Include such code in your template between <head> and </head> tags:

{% load revcanontags %}
{% revcanonical object %}

Of course, you should replace object with your own object variable. And, naturally, it should have get_absolute_url() method.

Additionally you can set your <a href> links to short urls:

{% load revcanontags %}
<a href="{% shorturl object %}">...</a>

Metadata

Release files for django-revcanonical 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-revcanonical 1.0
File Size Uploaded
django-revcanonical-1.0.tar.gz 3.6 kB Details

Release files / django-revcanonical-1.0.tar.gz

Download URL django-revcanonical-1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
726511c235ce0df2af2ca3a5ec024277ec0e544ec4839ad29933a85680feb9e1
BLAKE2b-256 checksum
How to use checksums
3cda77980e1361225e67fc50e1e673dcc0a81d4a393d68e724bf2667e7a14f04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page