003-mwalalearn-Django Introduction & Getting Started

Objectives: Django Introduction & Getting Started

Django Introduction & Getting Started

Django Introduction

(... content from Django Introduction here ...)

Django Getting Started

1. Python Installation

Django requires Python. To check if you already have Python installed, open your command prompt (Windows) or terminal (Mac/Linux) and run:

python --version

If Python is installed, you’ll see something like:

Python 3.13.2

If not, download it for free from python.org.

Real-life Example:

Checking Python version is like checking if your car has fuel before starting a trip. Without Python, Django cannot run.

Advice:

Always install the latest stable Python version. Older versions may not support the latest Django features.

2. PIP (Python Package Installer)

PIP is included with Python from version 3.4. It allows you to install Python packages like Django.

Check if PIP is installed by running:

pip --version

Example output:

pip 24.3.1 from C:\Program Files\WindowsApps\PythonVersion\Lib\site-packages\pip (python 3.13)

If you don’t have PIP, download it from pypi.org/project/pip.

Real-life Example:

PIP works like an app store for Python. Instead of manually downloading libraries, you just type a command and PIP installs it for you.

Advice:

If you face issues with pip, try using python -m pip install package_name. This ensures PIP runs with the right Python version.

3. Virtual Environment

It is recommended to create a virtual environment for every Django project. This keeps each project’s dependencies separate, avoiding version conflicts.

To create a virtual environment:

python -m venv myenv

Activate it:

  • Windows: myenv\Scripts\activate
  • Mac/Linux: source myenv/bin/activate

Once inside the virtual environment, install Django:

pip install django

Real-life Example:

A virtual environment is like having a separate kitchen for each type of cuisine. Italian food stays in one kitchen, Indian food in another — no ingredient conflicts.

Advice:

Always activate your virtual environment before working on your project. You’ll know it’s active when you see (myenv) at the start of your terminal line.

4. First Django Project

After installing Django, create your first project by running:

django-admin startproject myproject

Then navigate into the project and run the development server:

cd myproject
python manage.py runserver

Open http://127.0.0.1:8000/ in your browser, and you’ll see the Django welcome page.

Real-life Example:

This is like setting up a new diary. The diary is empty now, but ready for you to fill it with notes (apps, models, templates, etc.).

Advice:

Don’t rush to build big projects. Start with a small app like a To-Do List or Personal Blog to practice the basics.

Reference Book: N/A

Author name: SIR H.A.Mwala Work email: biasharaboraofficials@gmail.com
#MWALA_LEARN Powered by MwalaJS #https://mwalajs.biasharabora.com
#https://educenter.biasharabora.com

:: 1::