How to set up Django in Linux?

Django is a high-order Python framework that simplifies the creation of web applications. It offers a selection of tools and capabilities that allow developers to build reliable and scalable web applications quickly.

Setting up Django in Linux

To set up Django on Linux, you can follow this step-by-step approach.

  1. Firstly, check if Python is installed on your Linux system. To ensure that Python is installed, open the terminal and run the following command:

python --version
or
python3 --version

If Python is not pre-installed, you can install it by running the following command on your terminal:

sudo apt update
sudo apt install python3
  1. Next, install pip in your system. It is a package installer for Python. To install pip, run the following command in the terminal:

sudo apt install python3-pip
  1. To create a virtual environment for your Django projects, run the following commands on the terminal:

sudo apt install python3.10-venv
python3 -m venv myenv

This will create a new virtual environment named myenv in the current directory.

Note: Creating a virtual environment is an optional step but highly recommended. It is best practice to use a virtual environment to isolate your Django project's dependencies.

  1. The virtual environment should be activated when you work on your Django project. You can activate the environment using the following command:

source myenv/bin/activate
  1. As the virtual environment is activated, you can now install Django using pip:

pip install Django
  1. Verify the Django installation on your system by running the following command on the terminal:

django-admin --version
  1. Once you have verified the correct installation of Django on your system, you can now create a new Django project using the following command:

django-admin startproject myproject

This will create a new directory named myproject with the basic structure of a Django project.

  1. Lastly, navigate into your project directory and start the development server by running the following command on the terminal:

cd myproject
python manage.py runserver
  1. The development server will start running, and you can access your Django project by visiting http://localhost:8000 in your web browser.

Now you can start building your web application using Django’s powerful framework. You can create your Django project following these steps.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved