Skip to content

Commit 2d0b434

Browse files
Merge pull request #2664 from madeline-underwood/django
Refactor Django on GCP learning path documentation for clarity and co…_JA to sign off
2 parents 9c75a4b + 481047b commit 2d0b434

7 files changed

Lines changed: 279 additions & 187 deletions

File tree

content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
---
22
title: Deploy Django on Google Cloud C4A (Arm-based Axion VMs)
3-
4-
draft: true
5-
cascade:
6-
draft: true
73

84
minutes_to_complete: 30
95

10-
who_is_this_for: This learning path is intended for software developers deploying and optimizing Django-based web applications on Linux/Arm64 environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
6+
who_is_this_for: This Learning Path is for software developers deploying and optimizing Django-based web applications on Arm64 Linux environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
117

128
learning_objectives:
13-
- Provision an Arm-based SUSE SLES virtual machine on Google Cloud (C4A with Axion processors)
9+
- Provision an Arm-based SUSE Linux Enterprise Server (SLES) virtual machine on Google Cloud (C4A with Axion processors)
1410
- Install Django on a SUSE Arm64 (C4A) instance
1511
- Verify Django functionality by running the development server and accessing the default welcome page on the Arm64 VM
16-
- Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (Aarch64)
12+
- Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (aarch64)
1713

1814
prerequisites:
1915
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled

content/learning-paths/servers-and-cloud-computing/django-on-gcp/background.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
---
2-
title: Getting started with Django on Google Axion C4A (Arm Neoverse-V2)
2+
title: Get started with Django on Google Axion C4A (Arm Neoverse-V2)
33

44
weight: 2
55

66
layout: "learningpathall"
77
---
88

9-
## Google Axion C4A Arm instances in Google Cloud
9+
## Explore Axion C4A Arm instances in Google Cloud
1010

1111
Google Axion C4A is a family of Arm-based virtual machines built on Google’s custom Axion CPU, which is based on Arm Neoverse-V2 cores. Designed for high-performance and energy-efficient computing, these virtual machines offer strong performance for modern cloud workloads such as CI/CD pipelines, microservices, media processing, and general-purpose applications.
1212

1313
The C4A series provides a cost-effective alternative to x86 virtual machines while leveraging the scalability and performance benefits of the Arm architecture in Google Cloud.
1414

15-
To learn more about Google Axion, refer to the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog.
15+
To learn more about Google Axion, see the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog.
1616

17-
## Django
1817

19-
[Django](https://www.djangoproject.com/) is a high-level, **open-source Python web framework** that encourages **rapid development** and **clean, pragmatic design**. Developed and maintained by the [Django Software Foundation](https://www.djangoproject.com/foundation/), it simplifies web application development by handling much of the boilerplate and providing powerful built-in features.
18+
## Understand Django on Google Axion C4A (Arm Neoverse-V2)
2019

21-
Django follows the **Model–View–Template (MVT)** architectural pattern and includes robust tools for **authentication**, **URL routing**, **form handling**, **ORM (Object Relational Mapping)**, **session management**, and **administration interface** — all out of the box.
20+
Django is a high-level, open-source Python web framework that encourages rapid development and clean, pragmatic design. Developed and maintained by the [Django Software Foundation](https://www.djangoproject.com/foundation/), it simplifies web application development by handling much of the boilerplate and providing powerful built-in features.
2221

23-
Django is known for its focus on **security**, **scalability**, and **maintainability**, making it suitable for everything from small projects to large-scale enterprise applications. It helps developers build secure, high-performance web applications quickly without reinventing common components.
22+
Django follows the Model–View–Template (MVT) architectural pattern and includes robust tools for authentication, URL routing, form handling, ORM (Object Relational Mapping), session management, and administration interface - all out of the box.
23+
24+
Django is known for its focus on security, scalability, and maintainability, making it suitable for everything from small projects to large-scale enterprise applications. It helps developers build secure, high-performance web applications quickly without reinventing common components.
25+
26+
Common use cases include web applications, content management systems, APIs, e-commerce platforms, and data-driven dashboards. It integrates seamlessly with popular databases like PostgreSQL, MySQL, SQLite, and Oracle.
27+
28+
To learn more, visit the [Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/).
29+
30+
## Summary and what's next
31+
32+
You now understand the capabilities of Google Axion C4A Arm-based VMs and why Django is an excellent choice for building web applications on Arm infrastructure. The combination provides a cost-effective, high-performance platform for deploying Python web applications at scale.
33+
34+
In the next sections, you'll provision your own Arm-based VM on Google Cloud, install Django, and benchmark your application's performance. You're ready to start building!
2435

25-
Common use cases include **web applications**, **content management systems**, **APIs**, **e-commerce platforms**, and **data-driven dashboards**. It integrates seamlessly with popular databases like **PostgreSQL**, **MySQL**, **SQLite**, and **Oracle**.
2636

27-
To learn more, visit the [official Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/).
Lines changed: 89 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
---
2-
title: Django Baseline Testing on Google Axion C4A Arm Virtual Machine
2+
title: Verify Django installation and run the development server
33
weight: 6
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Django Baseline Testing on GCP SUSE VMs
10-
This baseline testing guide verifies that your **Django installation**, **web server**, and **basic application routing** are functioning correctly on a **Google Cloud SUSE Linux Arm64 (Axion C4A)** virtual machine.
11-
You will first run the Django development server and access it from your browser, then create a simple Django app to ensure routing works.
9+
## Verify Django is working on your Arm-based VM
1210

13-
### Baseline 1 — View Django Welcome Page
14-
This test confirms that Django is installed correctly and the server runs successfully.
11+
In this section, you'll confirm that Django is installed correctly and can serve web requests on your Google Cloud C4A VM. You'll create a Django project, run the development server, and access it from your browser. This hands-on verification ensures your environment is ready for development and testing.
12+
13+
By the end of this section, you'll have:
14+
- Created a Django project with proper directory structure
15+
- Configured Django to accept requests from your VM's external IP
16+
- Run the development server and accessed it from your browser
17+
- Built a simple Django app with custom routing and views
18+
- Verified that Django can handle HTTP requests and render responses
19+
20+
Let's get started!
21+
22+
## Create and test a basic Django project
1523

16-
#### Create a new Django project
1724
Run the following command to create a new Django project named `myproject`:
1825

1926
```console
@@ -32,33 +39,30 @@ myproject/
3239
├── asgi.py
3340
└── wsgi.py
3441
```
35-
- `manage.py` is Django’s command-line utility for project management (running server, migrations, etc.).
36-
- The inner `myproject/` folder contains the core configuration files that define your project’s settings and URLs.-
3742

38-
#### Run initial migrations
39-
Migrations prepare your project’s database by creating the required tables for Django’s internal apps (admin, authentication, etc.):
43+
The `manage.py` file is Django's command-line utility for project management. The inner `myproject/` folder contains your project's core settings and URL configuration.
44+
45+
## Run initial database migrations
46+
47+
Set up your project's database by running migrations, which create the required tables for Django's built-in apps:
4048

4149
```console
4250
python3 manage.py migrate
4351
```
4452

45-
You should get output showing the Running Migrations (all of which should be "OK").
53+
The output shows all migrations applied successfully (marked "OK").
4654

47-
#### Start the Django development server
48-
Before starting the Django development server, you must configure your ALLOWED_HOSTS setting to allow access from your VM’s external IP.
49-
This ensures that Django accepts HTTP requests from outside the localhost (e.g., when testing in a browser or from another machine).
55+
## Configure ALLOWED_HOSTS for external access
5056

51-
**ALLOWED_HOSTS:** is a security setting in Django that defines which host/domain names your Django site can serve.
57+
Before starting the Django development server, you must configure your `ALLOWED_HOSTS` setting to allow access from your VM's external IP. This ensures that Django accepts HTTP requests from outside localhost (for example, when testing in a browser from another machine).
5258

53-
- Navigate to Your Project Settings
54-
Move into your Django project directory where the settings.py file is located.
59+
Navigate to your project settings directory:
5560

56-
```console
57-
cd ~/myproject/myproject/
58-
```
61+
```console
62+
cd ~/myproject/myproject/
63+
```
5964

60-
- Open settings.py File
61-
Use any text editor (like vi or nano) to open the file ("edit" is used as an example below).
65+
Open `settings.py` using a text editor:
6266

6367
```console
6468
edit myproject/settings.py
@@ -67,60 +71,66 @@ This ensures that Django accepts HTTP requests from outside the localhost (e.g.,
6771
- Locate the `ALLOWED_HOSTS` Line
6872
Inside the file, find the following line:
6973

70-
```python
71-
ALLOWED_HOSTS = []
72-
```
73-
This setting defines which host/domain names Django will serve.
74+
```python
75+
ALLOWED_HOSTS = []
76+
```
77+
78+
Update it to allow your VM's external IP address:
7479

7580
- Allow All Hosts (for Testing Only)
7681
To make your Django app accessible from your VM’s external IP address, update it to:
7782
```python
7883
ALLOWED_HOSTS = ['*']
7984
```
8085
{{% notice Note %}}
81-
Allowing all hosts `('*')` is suitable **only for development or testing**.
82-
For production, replace `'*'` with specific domain names or IPs, such as your public IP address for your VM that you recorded earlier:
86+
For development and testing only, you can use `ALLOWED_HOSTS = ['*']` to allow all hosts. However, for production deployments, always specify explicit domain names or IP addresses such as `ALLOWED_HOSTS = ['your-external-ip', 'your-domain.com']`.
8387
{{% /notice %}}
8488

8589
```python
8690
ALLOWED_HOSTS = ['your-external-ip', 'your-domain.com']
8791
```
8892

89-
**Now start the Django development server:**
93+
Now that you've configured `ALLOWED_HOSTS`, start the development server:
9094

91-
We can now start the Django development server since we have exposed TCP/8000 in our VM via firewall rules:
9295
```console
9396
python3 manage.py runserver 0.0.0.0:8000
9497
```
9598

96-
#### View in browser
97-
Open a web browser on your local machine (Chrome, Firefox, Edge, etc.) and enter the following URL in the address bar. Please replace "YOUR_VM_EXTERNAL_IP" with the external IP address of your VM that you saved off earlier:
99+
This starts the Django development server on port 8000, listening on all network interfaces.
98100

99-
```console
101+
## Access Django in your browser
102+
103+
Open a web browser on your local machine and navigate to:
104+
105+
```
100106
http://<YOUR_VM_EXTERNAL_IP>:8000
101107
```
102-
- Replace `<YOUR_VM_EXTERNAL_IP>` with the public IP of your GCP VM.
103108

104-
If everything is set up correctly, you should see the default Django welcome page (“The install worked successfully!”). It looks like this:
109+
Replace `<YOUR_VM_EXTERNAL_IP>` with the public IP address of your GCP VM.
110+
111+
You should see the Django welcome page with the message "The install worked successfully!":
112+
113+
![Screenshot of the Django welcome page displayed in a web browser. The page features a large heading stating The install worked successfully followed by a subheading congratulating the user on successfully installing Django. Below are instructions for the next steps, including editing the settings file and reading the Django documentation. The page has a clean white background with blue highlights. alt-text#center](images/django-welcome-page.png "Django welcome page")
105114

106-
![Django welcome page alt-text#center](images/django-welcome-page.png "Figure 1: Django web page")
115+
## Build a simple Django app with custom routing
107116

108-
### Baseline 2 — Create a Simple Django App
109-
This test ensures Django’s application routing and view rendering work as expected.
117+
This section demonstrates that Django's application routing and view rendering work correctly by creating a simple app with a custom view.
110118

111-
#### Stop the server
112-
Press `Ctrl + C` to stop the Django server if running.
119+
## Stop the server
120+
121+
Press **Ctrl + C** in your terminal to stop the Django development server.
122+
123+
## Create a new Django app
113124

114-
#### Create a new app
115125
Within your Django project directory, create a new app named `hello`:
116126

117127
```console
118128
python3 manage.py startapp hello
119129
```
120130

121-
**This creates the following directory:**
131+
This generates the following directory structure with files for views, models, configuration, and more:
122132

123-
```markdown
133+
```output
124134
hello/
125135
├── admin.py
126136
├── apps.py
@@ -130,19 +140,22 @@ hello/
130140
└── urls.py
131141
```
132142

133-
#### Create a simple view
134-
Edit `hello/views.py`. Replace your existing file with this:
143+
## Define a view function
144+
145+
Edit `hello/views.py` and replace the entire file with:
135146

136147
```python
137148
from django.http import HttpResponse
138149

139150
def home(request):
140-
return HttpResponse("<h1>Hello, Django on GCP SUSE ARM64!</h1>")
151+
return HttpResponse("<h1>Hello, Django on Arm!</h1>")
141152
```
142-
This defines a simple view function that sends a basic HTML message as the HTTP response.
143153

144-
#### Create app URL configuration
145-
Create a new file `hello/urls.py` and add:
154+
This simple view function returns a basic HTML message as an HTTP response.
155+
156+
## Create URL configuration for your app
157+
158+
Create a new file `hello/urls.py`:
146159

147160
```python
148161
from django.urls import path
@@ -152,10 +165,12 @@ urlpatterns = [
152165
path('', views.home, name='home'),
153166
]
154167
```
155-
This maps the root URL `(/)`of your app to the `home()` view function.
156168

157-
#### Link the app to the main project
158-
Replace your default `myproject/urls.py` file with this version.
169+
This maps the root URL path to your `home()` view function.
170+
171+
## Include the app in your project's main URLs
172+
173+
Edit `myproject/urls.py` to include the `hello` app's URLs:
159174

160175
```python
161176
"""myproject URL Configuration
@@ -182,11 +197,12 @@ urlpatterns = [
182197
path('', include('hello.urls')),
183198
]
184199
```
185-
This tells Django to delegate routing for the root path (`''`) to the `hello` app’s URLs.
186200

187-
#### Add the app to settings
188-
This makes Django aware of your new app so it can load its configuration and routes.
189-
Edit `myproject/settings.py` → add `'hello'` to INSTALLED_APPS:
201+
This tells Django to route the root path to your `hello` app.
202+
203+
## Register the app in Django settings
204+
205+
Django needs to know about your new app. Edit `myproject/settings.py` and add `'hello'` to the `INSTALLED_APPS` list:
190206

191207
```python
192208
INSTALLED_APPS = [
@@ -199,18 +215,27 @@ INSTALLED_APPS = [
199215
'hello',
200216
]
201217
```
202-
#### Run the server again
218+
219+
## Start the server again
220+
221+
Restart the Django development server:
203222

204223
```console
205224
python3 manage.py runserver 0.0.0.0:8000
206225
```
207226

208-
#### Test your app
209-
Open in browser:
227+
## Test your custom app
228+
229+
Open your browser and navigate to:
210230

211-
```console
212-
http://<YOUR_VM_IP>:8000
213231
```
214-
You should see the Django app. It looks like this:
232+
http://<YOUR_VM_EXTERNAL_IP>:8000
233+
```
234+
235+
You should now see your custom message displayed:
236+
237+
![Screenshot of a web browser displaying a Django app with a large heading that reads Hello, Django on Arm centered on a clean white background. The page contains no additional content or navigation, creating a straightforward and welcoming tone. alt-text#center](images/django-app.png "Django custom app")
238+
239+
## Summary and what's next
215240

216-
![Django App alt-text#center](images/django-app.png "Figure 2: Django App")
241+
You've successfully verified that Django is installed and working on your Arm-based VM. Your application can serve web requests, handle routing, and render custom views. Great job, you're ready to benchmark your Django application!

0 commit comments

Comments
 (0)