You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md
+3-7Lines changed: 3 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,15 @@
1
1
---
2
2
title: Deploy Django on Google Cloud C4A (Arm-based Axion VMs)
3
-
4
-
draft: true
5
-
cascade:
6
-
draft: true
7
3
8
4
minutes_to_complete: 30
9
5
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.
11
7
12
8
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)
14
10
- Install Django on a SUSE Arm64 (C4A) instance
15
11
- 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)
17
13
18
14
prerequisites:
19
15
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/django-on-gcp/background.md
+18-9Lines changed: 18 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,36 @@
1
1
---
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)
3
3
4
4
weight: 2
5
5
6
6
layout: "learningpathall"
7
7
---
8
8
9
-
## Google Axion C4A Arm instances in Google Cloud
9
+
## Explore Axion C4A Arm instances in Google Cloud
10
10
11
11
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.
12
12
13
13
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.
14
14
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.
16
16
17
-
## Django
18
17
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)
20
19
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.
22
21
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!
24
35
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**.
26
36
27
-
To learn more, visit the [official Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/).
title: Django Baseline Testing on Google Axion C4A Arm Virtual Machine
2
+
title: Verify Django installation and run the development server
3
3
weight: 6
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
8
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
12
10
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
15
23
16
-
#### Create a new Django project
17
24
Run the following command to create a new Django project named `myproject`:
18
25
19
26
```console
@@ -32,33 +39,30 @@ myproject/
32
39
├── asgi.py
33
40
└── wsgi.py
34
41
```
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.-
37
42
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:
40
48
41
49
```console
42
50
python3 manage.py migrate
43
51
```
44
52
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").
46
54
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
50
56
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).
52
58
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:
55
60
56
-
```console
57
-
cd ~/myproject/myproject/
58
-
```
61
+
```console
62
+
cd ~/myproject/myproject/
63
+
```
59
64
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:
62
66
63
67
```console
64
68
edit myproject/settings.py
@@ -67,60 +71,66 @@ This ensures that Django accepts HTTP requests from outside the localhost (e.g.,
67
71
- Locate the `ALLOWED_HOSTS` Line
68
72
Inside the file, find the following line:
69
73
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:
74
79
75
80
- Allow All Hosts (for Testing Only)
76
81
To make your Django app accessible from your VM’s external IP address, update it to:
77
82
```python
78
83
ALLOWED_HOSTS= ['*']
79
84
```
80
85
{{% 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']`.
Now that you've configured `ALLOWED_HOSTS`, start the development server:
90
94
91
-
We can now start the Django development server since we have exposed TCP/8000 in our VM via firewall rules:
92
95
```console
93
96
python3 manage.py runserver 0.0.0.0:8000
94
97
```
95
98
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.
98
100
99
-
```console
101
+
## Access Django in your browser
102
+
103
+
Open a web browser on your local machine and navigate to:
104
+
105
+
```
100
106
http://<YOUR_VM_EXTERNAL_IP>:8000
101
107
```
102
-
- Replace `<YOUR_VM_EXTERNAL_IP>` with the public IP of your GCP VM.
103
108
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
+

105
114
106
-

115
+
## Build a simple Django app with custom routing
107
116
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.
110
118
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
113
124
114
-
#### Create a new app
115
125
Within your Django project directory, create a new app named `hello`:
116
126
117
127
```console
118
128
python3 manage.py startapp hello
119
129
```
120
130
121
-
**This creates the following directory:**
131
+
This generates the following directory structure with files for views, models, configuration, and more:
122
132
123
-
```markdown
133
+
```output
124
134
hello/
125
135
├── admin.py
126
136
├── apps.py
@@ -130,19 +140,22 @@ hello/
130
140
└── urls.py
131
141
```
132
142
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:
135
146
136
147
```python
137
148
from django.http import HttpResponse
138
149
139
150
defhome(request):
140
-
return HttpResponse("<h1>Hello, Django on GCP SUSE ARM64!</h1>")
151
+
return HttpResponse("<h1>Hello, Django on Arm!</h1>")
141
152
```
142
-
This defines a simple view function that sends a basic HTML message as the HTTP response.
143
153
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`:
146
159
147
160
```python
148
161
from django.urls import path
@@ -152,10 +165,12 @@ urlpatterns = [
152
165
path('', views.home, name='home'),
153
166
]
154
167
```
155
-
This maps the root URL `(/)`of your app to the `home()` view function.
156
168
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:
159
174
160
175
```python
161
176
"""myproject URL Configuration
@@ -182,11 +197,12 @@ urlpatterns = [
182
197
path('', include('hello.urls')),
183
198
]
184
199
```
185
-
This tells Django to delegate routing for the root path (`''`) to the `hello` app’s URLs.
186
200
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:
190
206
191
207
```python
192
208
INSTALLED_APPS= [
@@ -199,18 +215,27 @@ INSTALLED_APPS = [
199
215
'hello',
200
216
]
201
217
```
202
-
#### Run the server again
218
+
219
+
## Start the server again
220
+
221
+
Restart the Django development server:
203
222
204
223
```console
205
224
python3 manage.py runserver 0.0.0.0:8000
206
225
```
207
226
208
-
#### Test your app
209
-
Open in browser:
227
+
## Test your custom app
228
+
229
+
Open your browser and navigate to:
210
230
211
-
```console
212
-
http://<YOUR_VM_IP>:8000
213
231
```
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
+

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