Google:

adverisment

How to install Django on Linux, Mac and Windows

details img

Step 1: Install Python

Django requires Python. Ensure you have Python installed.

  1. Check if Python is installed:

    bash
    python --version

    or

    bash
    python3 --version
  2. Download Python (if not installed):


Step 2: Install pip (Python Package Manager)

Pip is often included with Python. To verify:

bash
pip --version

If pip is not installed, you can install it using:

bash
python -m ensurepip --upgrade

Step 3: Set Up a Virtual Environment (Optional but Recommended)

A virtual environment isolates your Django project dependencies.

  1. Install virtualenv (if not installed):

    bash
    pip install virtualenv
  2. Create a virtual environment:

    bash
    python -m venv myenv
  3. Activate the virtual environment:

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

Step 4: Install Django

Once the virtual environment is activated, install Django using pip.

bash
pip install django

Verify the installation:

bash
django-admin --version

Step 5: Create a Django Project

  1. Create a new project:

    bash
    django-admin startproject myproject
  2. Navigate to the project directory:

    bash
    cd myproject
  3. Run the development server:

    bash
    python manage.py runserver
  4. Open a web browser and navigate to:

    arduino
    http://127.0.0.1:8000/

    You should see the default Django welcome page.


Step 6: Explore and Develop

  • Use python manage.py startapp appname to create an app within your project.
  • Edit settings and routes (settings.py and urls.py) to customize your project.

Optional: Install Additional Tools

  • Django Debug Toolbar: For debugging during development:
    bash
    pip install django-debug-toolbar
  • Database Connectors: For PostgreSQL, MySQL, etc.

Leave Comment