django-brevisurl

A Django app for shortening URLs
Download

django-brevisurl Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • VladimĂ­r Gorej
  • Publisher web site:
  • http://www.codescale.net/

django-brevisurl Tags


django-brevisurl Description

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.InstallationInstall via pypi or copy this module into your project or into your PYTHONPATH.Put brevisurl into INSTALLED_APPS in your projects settings.py fileINSTALLED_APPS = ( 'localeurl', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.sitemaps', 'web', 'debug_toolbar', 'rosetta', 'south', 'brevisurl')Run syncdb command to create database tables from brevisurl modelspython manage.py syncdbConfigurationdjango settings.py constants# Setting for default brevis backendBREVISURL_BACKEND = 'brevisurl.backends.local.BrevisUrlBackend' # Default is 'brevisurl.backends.local.BrevisUrlBackend'Append brevisurl url patterns to your urls.py at the end of module, if you're using local backendurlpatterns += patterns('', # brevisurl urls (r'^', include('brevisurl.urls')))ExamplesExample 1Using programmatic approachfrom brevisurl import get_connectionconnection = get_connection()short_url_obj = connection.shorten_url('http://www.codescale.net/')print short_url_obj.shortened_urlExample 2Using programmatic approach with shortcutfrom brevisurl import shorten_urlshor_url_obj = shorten_url('http://www.codescale.net/')print shor_url_obj.shortened_urlExample 3Using brevisurl in templates via filter approach{% load brevisurl %}{% url homepage as homepage_url %}{{ homepage_url|shorten_url }}Example 4Using 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 }}TestsTested on evnironment- Xubuntu Linux 12.04 LTS precise 64-bit- Python 2.7.3+- Python unittest- Django 1.4Running testsTo run the test run command: python manage.py test brevisurlProduct's homepage


django-brevisurl Related Software