A simple Django App to hold short links mapped to long urls used in your projects.
Project description
django-shortlink
A simple Django App to hold short links mapped to long urls used in your projects.
Requirements
To use this package following needed. if not provided will be installed automatically.
Django>=2.0
Installation
Note: This package is well tested on django>=2.0
. But if you are using older versions can be
used with minor changes in structure.
install using pip:
$ pip install django-shortlink
Usage
Register app in settings.py
INSTALLED_APPS = [
"django_shortlink",
]
update urls.py
like below:
urlpatterns += [
...
re_path(r'', include('shortlink.urls')),
...
Now set Setting variables, If not will use default values as below:
SHORTEN_PATH_LENGTH = 8
SHORTLINK_URL_BASE = 's/'
HOST_ADDRESS = 'http://localhost:8000'
Now to create shortlink, pass your full_url like this:
from shortlink.models import ShortLink
s = ShortLink.objects.create(full_url="https://test.com")
print(s.short_url)
short_url
is the shorten url that you should give users.
If they click on it, methods in views.py
will be triggered
and if short_url is valid, will redirect to full_url
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_shortlink-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b4c8dbd9cf0044be2b1d602f1bd82114cc39ec7414f08219ddc641f2c090ad7 |
|
MD5 | 3f21f60c030db575f750f4e13984ca7f |
|
BLAKE2b-256 | d12e4497663b63ade8e8a1be6770b47f3221d1741661f5e87ef8d797ee32f19a |