This guide is designed to point you to the best information about getting started with Django-Shorty.
To get started with Django-Shorty you must have the following installed:
- Python 2.4+. Do not install Python 3+. Django-Shorty is not compatible with Python 3 yet.
- pysqlite or any other database driver is required.
- virtualenv 1.4.7+ ( Optional )
Download the latest Django-Shorty version and unpackit. Enter into the Django-Shorty folder and type this command:
$ python setup.py install
or use pip:
$ pip install django-shorty
Django-Shorty is now installed!
Create a new Django project, now edit the settings.py file. Goto INSTALLED_APPS and add shorty app and active the administration interface
INSTALLED_APPS = (
........
'django.contrib.admin',
'shorty',
)
Now you need to add the variables of Django-Shorty app. Have 4 variables:
To configure the defaults url you need to use include:
1 | url(r'^', include('shorty.urls')),
|
this code is valid if you want to add Django-Shorty as Home Page
The templates file are:
the name of the form template variable is the same in the add view and in the password check view, shorty_form Ex:
shorty/add.html
<form action="." method="post">
{% csrf_token %}
{{ shorty_form.as_p }}
<input type="submit" value="Submit" />
</form>
shorty/private.html
<form action="." method="post">
{% csrf_token %}
{{ shorty_form.as_p }}
<input type="submit" value="Submit" />
</form>
The shorty/add.html have other template variable. When the process is completed the page return to the add view and if you want to show the slug code you can use the url_slug
<form action="." method="post">
{% csrf_token %}
{{ shorty_form.as_p }}
<input type="submit" value="Submit" />
</form>
The Short URL:
{% if url_slug %}
http://ttt.io/{{ url_slug }}
{% endif %}