Fork Me on GitHub


URL Shortener in Django

download .ZIPdownload .TGZ


Mutaku URL Shortener


STUMPy is a URL shortener written by xiao_haozi (Mutaku) using the django python web framework.


There are many url shorteners out there, and STUMPy does not do anything groundbreaking. However, there are several benefits that encouraged it's development:


{requirement [link for source]}


See: "Django Install": Once you have django installed and running, you can checkout the repo and test things out in a few steps.

►Grab the latest release with git.

git clone

►Setup a mysql database that stumpy can access.

create database stumpy;
grant all on stumpy.* to 'SOMEUSER@localhost' identified by "SOMEPASS";
flush privilieges;

►Copy the file to .


►If you do not have a SECRET_KEY generated in Django you will need to generate one by running the keygen script and copy that key into your file in the next step.


►Edit the file and add in your appropriate database variables and your secret key you already had from django or the one you generated above.

►Sync the database to the models.

python syncdb

►Fire up the server and navigate to /admin in your browser. Go to sites->sites and edit the domain name to match the domain you are using. This will initially be set to ''.

python runserver


See: "Deploying Django": Once you have your webserver setup to serve the static files, you can set DEBUG=False. Without doing so, static files will not be served up by Django in production mode (DEBUG=False). Additionally, ensure that you have set your proper FQDN through the admin interface as mentioned in the last step of the setup section.

I have included an example fastcgi script (stumpy.fcgi) that you may point to with your webserver to run Stumpy in a production setting. The following is an example of a stanza that you could use with Lighttpd to serve up Stumpy.

$HTTP["host"] =~ "" {
  server.document-root = "/home/JohnDoe/Stumpy/"
  fastcgi.server = ( ".fcgi" =>
                     ( "localhost" => (
             "socket" => "/var/lib/lighttpd/stumpy-fastcgi.socket",
                         "bin-path" => "/home/JohnDoe/Stumpy/stumpy.fcgi",
                         "check-local" => "disable",
                         "min-procs" => 2,
             "max-procs" => 4,
  alias.url = ( "/static/admin"  => "/home/JohnDoe/django/contrib/admin/media/" )
  url.rewrite-once = ( "^(/static/.*)$" => "$1",
                       "^/favicon\.ico$" => "/static/favicon.ico",
               "^(/.*)$" => "/stumpy.fcgi$1" )


You will probably be able to see from the how to go about using Stumpy. Here's the rundown:

*-> These views require authenticated_user and uses sessions


A bookmarklet is ready to use and can be found by visiting the index page ("/") and dragging the 'stumpy it!' link to your bookmarks bar.

To add additional users that may submit URLs, add the user via the admin interface. They do not need to have any admin interface abilities to simply login and and submit URLs. If you want a user to have permission to edit and delete urls (why?) you would have to enable those permissions in the user management in the admin interface.


[coming soon]


Most of the information you might need can be found in the Django docs here: "Django": For Stumpy specific help, see "Stumpy":

"); pageTracker._trackPageview(); } catch(err) {}