Django Tutorial #2 - Setup & Installation

3 min read 7 months ago
Published on Aug 15, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the setup and installation of Django, a powerful web framework for building web applications using Python. By the end of this guide, you'll have a Django project up and running, ready for development.

Step 1: Install Python

Before installing Django, ensure you have Python installed on your system. Follow these steps:

  1. Check Python Installation

    • Open a terminal or command prompt.
    • Type python --version or python3 --version to check if Python is installed.
  2. Download Python

    • If Python is not installed, download it from the official website: python.org.
    • Follow the installation instructions for your operating system (Windows, macOS, or Linux).
  3. Add Python to PATH

    • During installation on Windows, ensure you check the box to add Python to your PATH.

Step 2: Install Django

Once Python is installed, you can proceed with installing Django.

  1. Open Terminal or Command Prompt

    • Ensure you have access to a terminal or command prompt.
  2. Install Django with pip

    • Run the following command:
      pip install django
      
    • This command will download and install the latest version of Django from the Python Package Index (PyPI).
  3. Verify Django Installation

    • After installation, check the version of Django by running:
      python -m django --version
      
    • Ensure that it displays the installed version without errors.

Step 3: Create a New Django Project

Now that Django is installed, you can create a new project.

  1. Navigate to Your Development Directory

    • Use the cd command to navigate to the folder where you want your project:
      cd path/to/your/development/directory
      
  2. Start a New Django Project

    • Run the following command to create a new project named "myproject":
      django-admin startproject myproject
      
  3. Navigate into Your Project

    • Change into the project directory:
      cd myproject
      

Step 4: Run the Development Server

To see your Django project in action, start the development server.

  1. Run the Server

    • Execute the command:
      python manage.py runserver
      
  2. Access the Development Server

    • Open a web browser and go to http://127.0.0.1:8000/.
    • You should see the Django welcome page, indicating that your project is set up correctly.

Step 5: Explore Project Structure

Familiarize yourself with the structure of your new Django project.

  1. Key Files and Directories

    • manage.py: A command-line utility for interacting with your project.
    • settings.py: Configuration settings for your Django project.
    • urls.py: URL routing for your application.
    • wsgi.py: Entry point for WSGI-compatible web servers to serve your project.
  2. Understanding the Structure

    • Each of these files plays a crucial role in the functionality of your Django application.

Conclusion

You have successfully set up and installed Django, created a new project, and run the development server. From here, you can start building your web application by adding models, views, and templates.

Next Steps

  • Explore the Django documentation: Django docs
  • Begin learning about creating models and views to develop your application further.
  • Consider accessing premium courses on platforms like Net Ninja Pro for in-depth learning.