Skip to main content

Shrink a URL using an internal or external shortening service

Project description

This package generates short URLs when given longer ones. These can be generated by the app, with a 7 (by default) character short-name, or by an external provider, like

About Bambu Tools 2.0

This is part of a toolset called Bambu Tools. It’s being moved from a namespace of bambu to its own ‘root-level’ package, along with all the other tools in the set. If you’re upgrading from a version prior to 2.0, please make sure to update your code to use bambu_urlshortener rather than bambu.urlshortener.


Install the package via Pip:

pip install bambu-urlshortener

Add it to your INSTALLED_APPS list:


To use internal URL shortening - rather than a service like - add the middleware to your settings:


This should be added as close to the end of your middleware list as possible, as it looks for 404 responses and tries to find a URL short-name corresponding to the requested path.

Run syncdb or migrate to setup the database tables.

Basic usage

Simply call bambu_urlshortener.shorten, passing in the long URL.


There are two in-built shortening providers:


This default option, coupled with the middleware allows a web app to provide its own short URLs.


Calls the API and returns a short URL. Specify the API key via the SHORTURL_TOKEN setting. Optionally set the SHORTURL_DOMAIN setting if you want to use a custom domain name.


  • Write more tests

Questions or suggestions?

Find me on Twitter (@iamsteadman) or visit my blog.

Project details

Download files

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

Files for bambu-urlshortener, version 2.0
Filename, size File type Python version Upload date Hashes
Filename, size bambu-urlshortener-2.0.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page