django-brevisurl icondjango-brevisurl 1.0

A Django app for shortening URLs
django-brevisurl is a Django app for shortening URLs. Brevis is a latin word, which means short, so the name brevisurl == shorturl or url shortener. The actual creating of short url is handled by the shortening backend.


Install via pypi or copy this module into your project or into your PYTHONPATH.

Put brevisurl into INSTALLED_APPS in your projects file


Run syncdb command to create database tables from brevisurl models

python syncdb


django constants

# Setting for default brevis backend
BREVISURL_BACKEND = 'brevisurl.backends.local.BrevisUrlBackend' # Default is 'brevisurl.backends.local.BrevisUrlBackend'

Append brevisurl url patterns to your at the end of module, if you're using local backend

urlpatterns += patterns('',
 # brevisurl urls
 (r'^', include('brevisurl.urls'))


Example 1

Using programmatic approach

from brevisurl import get_connection

connection = get_connection()
short_url_obj = connection.shorten_url('')
print short_url_obj.shortened_url

Example 2

Using programmatic approach with shortcut

from brevisurl import shorten_url

shor_url_obj = shorten_url('')
print shor_url_obj.shortened_url

Example 3

Using brevisurl in templates via filter approach

{% load brevisurl %}
{% url homepage as homepage_url %}
{{ homepage_url|shorten_url }}

Example 4

Using brevisurl in templates with filtered tag approach. brevisurl comes with special tag called absurl that works exactly the same as url django tag but prepends protocol + domain in front of resovled url path.

{% load brevisurltags %}
{% absurl homepage as homepage_url %}
{{ homepage_url|shorten_url }}


Tested on evnironment

- Xubuntu Linux 12.04 LTS precise 64-bit
- Python 2.7.3+
- Python unittest
- Django 1.4

Running tests

To run the test run command:

 python test brevisurl

last updated on:
September 18th, 2012, 18:44 GMT
developed by:
VladimĂ­r Gorej
license type:
BSD License 
ROOT \ Internet \ HTTP (WWW)


In a hurry? Add it to your Download Basket!

user rating



Add your review!