URL Shortener Project in Django with Source Code

URL Shortener Project in Django with Source Code – This Django-based URL Shortener Project can handle everything from tweaking the abbreviated URL code to programming it to generate random slugs for the shorter URL.

This system project also includes an admin portal through which all shortened URLs, as well as their redirected links, may be monitored.

Importance of URL Shortener Project in Django

Shortening your URL links is important because an audience is more likely to believe and click a shorter link (if it is shared from a reliable source) than a longer link.

Shortener Project in Django Beneficiaries

  • google drive

Shortener Project in Django: Project Details and Technology

Project Name:Shortener Project in Django With Source Code
AbstractShortener Project in Django – A URL shortener is a program that generates a short, unique URL that redirects to the website you choose. In a nutshell, they make a URL shorter and easier to remember. The address of the shortener site will usually be included in your new, shorter URL, along with a string of random letters.
Language/s Used:Python Django Web Framework
Python version (Recommended):3.9
Type:Website, Web Application
Developer:Source Code Hero

Shortener Project in Django

The Python Django Framework was used to develop the URL Shortener Project. The system is built entirely in Django Framework for the backend and HTML and CSS for the front end.

Django is a high-level Python Web framework that promotes quick development and a minimalistic aesthetic.

URL Shortener Project in Django: Major Functionalities

  • How to Use URL Shortener
  • List of all the Links Shortened till date
  • Create a Short URL

What is Django?

Django is a high-level Python web framework for building safe and maintainable websites quickly.

Django provides a framework that has been built to “do the right things” to defend the website automatically, which helps developers avoid many typical security blunders.

Before you begin working on a URL Shortener in Django with Source Code, make sure you are familiar with CSS, JavaScript, PHP, and Python.

URL Shortener Project in Django Steps on How to Run the Project

Time needed: 3 minutes

These are the steps to run a URL Shortener Project in Django

  1. pip install virtualenv

    First, You need to install the virtualenv, Open a command prompt by going to the project folder directory and typing CMD. After opening the CMD type ” pip install virtualenv “.
    install virtual env in URL Shortener Project in Django with Source Code

  2. virtualenv env

    Then, after installing virtualenv just type “virtualenv env” and enter. A virtual environment is a tool that creates separate Python virtual environments for distinct projects to keep their dependencies separate. Most Python programmers utilize this as one of their most significant tools.

  3. cd env/Scripts

    Next, just type ” cd env/Scripts ” and press enter. It can be any script that includes data loading, processing, and cleaning, or any ML phase while developing an application when putting business logic directly in views or models isn’t always the best option.
    env in URL Shortener Project in Django with Source Code

  4. activate

    Next, you need to type “activate” and then press enter. The virtual environment will be turned on, and you’ll see “(project-name)” next to the command prompt to identify it. You’ll have to activate the environment every time you open a new command prompt.
    activate in URL Shortener Project in Django with Source Code

  5. cd ../..

    Next, just type ” cd ../..  ” and press enter.

    cd in URL Shortener Project in Django with Source Code

  6. Install Django

    Next, type the command “pip install django”. This will download and install the most recent version of Django.
    After the installation is complete, use the command prompt to check your Django installation by typing django-admin —version.
    install django in URL Shortener Project in Django with Source Code

  7. python manage.py makemigrations

    Next, after installing the Django type this command ” python manage.py makemigrations ” to create a table in the database. makemigrations provides SQL instructions for preinstalled applications (which can be seen in installed apps in settings.py) and your newly generated apps’ model, which you may add to installed apps.

    Those commands in your database file are not executed. As a result, no tables are created after makemigrations.
    makemigrations in URL Shortener Project in Django with Source Code

  8. python manage.py migrate –-run-syncdb

    Next, after making migrations type this command ” python manage.py migrate –-run-syncdb ” to migrate the tables in the database.

    Initial database tables (including auth, auth group permission, Django admin log, and others) will not be generated if you don’t use syncdb before completing the migration.

  9. python manage.py createsuperuser

    After the migration of the database, you need to create a super user to login in to the admin account, just you need to type the command ” python manage.py createsuperuser “.

    Using manage.py, you may establish a “superuser” account with complete access to the site and all necessary permissions.

    To create the superuser, run the following script in the same directory as manage.py. You’ll be asked to create a username, email address, and a secure password.

  10. python manage.py runserver

    Lastly, after creating super user just type the command ” python manage.py runserver “.

    It should only be used for testing and launching your project; it should not be utilized for live website deployment.

    The runserver management command is designed for purposes other than running a web server. The development server automatically reloads Python code for each request as needed, which is ideal for local development but would add extra overhead in a production setting (source):


    Finally, To access your project dashboard, type or copy this “” into your browser. It is possible to imitate a web-server environment with localhost, and it is most commonly used to simulate web applications operating on a web server. : The port number on which the browser communicates to the server is 8000.
    copy url in URL Shortener Project in Django with Source Code

Download Source Code Here!

Anyway, if you want to improve your programming skills, particularly in Python, check out my new post  Free Django Projects with Source Code for Beginners.

However, if you want to focus on web development with Django, you may get source code for real-world applications from our list of Best Django Projects.


Finally, this URL Shortener in Django With Source Code may be useful for students and professionals learning the Python Django programming language.

This project may be customized to match your requirements. I hope this project will help you hone your skills. I wish you the best of luck in your programming endeavors!


If you have any questions or suggestions about URL Shortener in Django With Source Code, please feel free to leave a comment below.

Leave a Comment