# Install Django on your Arm-based VM

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/)
- [Get started with Django on Google Axion C4A](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/background/)
- [Configure firewall rules for Django on Google Cloud](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/firewall_setup/)
- [Create a Google Axion C4A Arm virtual machine on GCP](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/instance/)
- [Install Django on your Arm-based VM](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/installation/)
- [Verify Django installation and run the development server](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/baseline/)
- [Deploy Django on GKE Axion with managed data services](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/overview-and-infrastructure/)
- [Build a Django REST API with PostgreSQL and Redis](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/django_application/)
- [Containerize and deploy Django on Axion GKE](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/containerization-and-deploy/)
- [Benchmark Django application performance on Arm](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/benchmarking/)
- [Next Steps](https://learn.arm.com/learning-paths/servers-and-cloud-computing/django-on-gcp/_next-steps/)

## Install Django and dependencies
After connecting to your SUSE Linux Enterprise Server (SLES) VM using SSH, you’ll install the Google Cloud CLI, update your system, install Python 3.11, and set up a virtual environment for your Django project.

## Prepare the system
Update the system packages and install dependencies:
```
sudo zypper refresh
sudo zypper update -y
sudo zypper install -y curl git tar gzip
```

## Install Python 3.11
Install Python 3.11:
```
sudo zypper install -y python311
which python3.11
```
Verify that Python and pip are installed correctly:
```
python3.11 --version
pip3.11 --version
```
The output is similar to:
```
__output__Python 3.11.10
__output__pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
```

## Install Google Cloud CLI (gcloud)
The Google Cloud CLI is required to authenticate with GCP and allow your Django application VM to interact with Google Cloud services such as GKE, Cloud SQL, Artifact Registry, Memorystore, and to build, deploy, and operate the Django platform.

Download and extract the Google Cloud SDK:
```
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-460.0.0-linux-arm.tar.gz
tar -xvf google-cloud-sdk-460.0.0-linux-arm.tar.gz
```
Install gcloud:
```
./google-cloud-sdk/install.sh
```
After installation completes, exit and reconnect to apply the PATH changes:
```
exit
```

## Initialize gcloud
Authenticate and configure the Google Cloud CLI:
```
gcloud init
```
During initialization, select **Login with a new account**. You’ll be prompted to authenticate using your browser and receive an auth code to copy back. Select the project you want to use and choose default settings when unsure.

## Verify authentication
```
gcloud auth list
```
The output is similar to:
```
__output__Credentialed Accounts
__output__ACTIVE  ACCOUNT
__output__*       <PROJECT_NUMBER>-compute@developer.gserviceaccount.com
```

## Create a project directory and virtual environment
Create a dedicated directory for your Django project and set up a Python virtual environment to isolate your project’s dependencies:
```
mkdir ~/myproject && cd ~/myproject
python3.11 -m venv venv
source venv/bin/activate
```
The `python3.11 -m venv venv` command creates an isolated Python environment named `venv` inside your project folder. Running `source venv/bin/activate` activates this environment.

Once activated, your command prompt displays `(venv)` at the beginning, indicating that you’re working inside an isolated Python environment.

## Upgrade pip and install Django
With your virtual environment active, upgrade pip to the latest version:
```
python3 -m pip install --upgrade pip
```
Now install Django and additional useful packages for web development:
```
python3 -m pip install django gunicorn
```
This installs:
- **Django** - the web framework for building your application
- **Gunicorn** - a production-ready WSGI (Web Server Gateway Interface) server for running Django applications

Verify that Django is installed correctly:
```
django-admin --version
```
The output is similar to:
```
__output__5.2.10
```

## What you’ve accomplished and what’s next
In this section, you installed:
- Google Cloud CLI for GCP service management
- Python 3.11 with a virtual environment
- Django and Gunicorn for web application development

Next, you’ll verify Django is working by creating a basic project and running the development server.
