Installing Django on Windows, macOS, and Linux

Tutorial 1 of 5

1. Introduction

This tutorial's goal is to guide you through the process of installing Django on three major operating systems: Windows, macOS, and Linux.

By the end of this tutorial, you will be able to:
- Understand the prerequisites for installing Django.
- Install Django on your system whether it is Windows, macOS, or Linux.

Prerequisites:
- Basic knowledge of using Command Line Interface (CLI).
- Python installed on your system (Python 3 is recommended).

2. Step-by-Step Guide

Windows

  1. Open the command prompt by searching for cmd in the start menu.
  2. First, we need to update pip, the Python package installer. Type and enter the following command:
    python -m pip install --upgrade pip
  3. Next, install Django by entering:
    pip install Django

macOS

  1. Open Terminal.
  2. Update pip:
    pip3 install --upgrade pip
  3. Install Django:
    pip3 install Django

Linux

  1. Open Terminal.
  2. Update pip:
    pip3 install --upgrade pip
  3. Install Django:
    pip3 install Django

3. Code Examples

After installing Django, you can verify the installation by checking the Django version. Type the following command in your respective terminal or command prompt:

python -m django --version

or

python3 -m django --version

The terminal should return the version of Django that you installed, which indicates that the installation was successful.

4. Summary

In this tutorial, you learned about the prerequisites for installing Django and how to install Django on Windows, macOS, and Linux. The next step would be to create a new Django project and start developing. You can learn more about Django from its official documentation (https://docs.djangoproject.com/en/3.2/).

5. Practice Exercises

  1. Create a new Django project.
  2. Hint: Use the command django-admin startproject projectname.
  3. Run the Django development server and open it in your web browser.
  4. Hint: Use the commands cd projectname and python manage.py runserver.

Solutions:
1. After creating a new Django project with django-admin startproject myproject, you should see a new directory named myproject in your current directory.
2. When you run python manage.py runserver, Django will start a development server at http://127.0.0.1:8000/. Open this URL in your web browser to see your Django application.

For further practice, try to create a new Django application within your project. Use the Django documentation as a guide.