Table of Contents

Installation

  1. Install django-weeny using pip or get latest stable release from Bitbucket.

    $ pip install django-weeny
    
  2. Make sure you have enabled the django.contrib.sites and south.

  3. Add weeny to INSTALLED_APPS.

    INSTALLED_APPS = (
        ...
        'django.contrib.sites',
        'south',
        'weeny',
        ...
    )
    
  4. Include weeny.urls.py in your urlconf.

    urlpatterns = patterns('',
        ...
        url(r'^weeny/', include("weeny.urls")),
        ...
    )
    

    Tip

    You can use whatever url prefix you’d like for the weeny app. For instance, in the current example you would get short urls like this: https://myfantasticsite.com/weeny/PxAwd7/

  5. Install migrations.

    $ python manage.py migrate weeny
    

Usage

Add a Weeny Site

The weeny is using the django.contrib.sites app in order to wire up URL’s.

  1. In the django admin interface, click the Add new weeny site icon to get started.

    _images/add_weeny_site1.png
  2. Site

    From the drop-down, select the site you wish to associate your URL’s with. It is important that this domain is the domain you are hosting your site on. When URL redirection occurs, this is the domain which will be used.

    _images/add_weeny_site2.png
  3. Short domain name

    Enter the short domain name for this site. This option is not used unless you check the Redirect to short domain option below. You’ll also need to register a real hostname and make sure it points to this site for this to work.

  4. Redirect to short domain

    Check this if you want your URL’s to redirect to this domain name instead of the Site domain name.

  5. Protocol

    Choose what transport protocol you want the URL’s for this site to use.

  6. Track

    The Track option specifies whether you want to track ALL URL’s for this domain.

  7. The read-only attribute Seed is a unique seed which will be used to generate URL’s for this domain.

Add a Weeny URL

Next step is to add a URL.

  1. Click the Add new Weeny URL icon to get started.

    _images/add_weeny_url1.png
  2. From the drop-down list, choose your weeny site.

    _images/add_weeny_url2.png
  3. Content type and Object ID

    Tip

    If you are not familiar with the Content-Types framework, you might want to read a little about it. It’s awesome, and one of my favorite django features! In short it is a way of creating Generic relations between objects, which means that we can have database relations between any models we’d like without knowing anything about them beforehand. The only requirements is that you know what kind of object it is, and the primary key of the requested object.

    Choose your model and object ID.

    Warning

    The target content object must have a get_absolute_url method implemented!

  4. URL code

    This is the code you’ll append to the short-url.

    For instance, if you wired up weeny.urls.py to /weeny/, the short URL for this object would be /weeny/l/.

  5. Privacy and moderation options

    _images/add_weeny_url3.png

    These options should be pretty self-explanatory.

    • Private URL

      Check this if you’d like user to enter a password to complete the redirect. You’ll also need to enter a password in the password field below.

    • Track

      Enable URL tracking for this URL. If URL tracking is enabled on the related Weeny site, this option does nothing.

    • Active

      Inactive URL’s does not work!

    • Allow revisit

      Uncheck to make URL single use.

About

Django-Weeny is a small and simple URL shortener app for Django. It supports basic features like:

  • Creating short-URL’s for any database object through Generic Relations
  • URL tracking
  • Password protection for single URL’s

Planned features

  • Moderation system
  • Template tags for resolving short-URL’s
  • Basic statistics through the django admin interface
  • Admin actions for various administration actions

Requirements

Python packages

The python requirements are automatically installed if installing with pip or running python setup.py install using the source distribution.

  • Django >= 1.5.0
  • PyYAML
  • South
  • ua-parser
  • user-agents

Django apps

Django-Weeny requires the following django apps to be enabled:

  • django.contrib.sites
  • django.contrib.contenttypes
  • south

Want to contribute?

We’d love django-weeny to get even better!

Submit your patches at Bitbucket!

Indices and tables