Page 2: Django Code Writing and Latest SQLite Installation

Modify the view and URL configurations of your Django application to display a simple "Hello, World!" web page, and install the latest SQLite database.


3. Django Code (Hello World)

Create a hello_world view function in the hello app and configure its URL. Register the hello app in the project's main settings.py file and set ALLOWED_HOSTS.

# Create hello/views.py and write content
cat > hello/views.py << EOF
from django.http import HttpResponse
def hello_world(request):
    return HttpResponse("Hello, World!")
EOF
# Create hello/urls.py and write content
cat > hello/urls.py << EOF
from django.urls import path
from .views import hello_world
urlpatterns = [ path('', hello_world), ]
EOF
# Modify config/urls.py: Include 'hello' app's URLs
sed -i "/from django.contrib import admin/a from django.urls import include" config/urls.py
sed -i "/urlpatterns = \[/a     path('', include('hello.urls'))," config/urls.py
# Modify settings.py: Register 'hello' app and set ALLOWED_HOSTS
sed -i "/'django.contrib.staticfiles'/a     'hello'," config/settings.py
sed -i "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = ['*']/" config/settings.py # For production, specify specific domains

4. Install Latest SQLite

Install the latest version of SQLite, Django's default database, by compiling from source to ensure stability and access to the latest features.

cd /usr/src # Change to source download directory
sudo wget https://www.sqlite.org/2025/sqlite-autoconf-3500100.tar.gz # Download latest SQLite version (check for newer versions)
sudo tar xvf sqlite-autoconf-3500100.tar.gz # Extract archive
cd sqlite-autoconf-3500100 # Change to extracted directory
./configure --prefix=/usr/local # Configure environment with install path
make # Compile
sudo make install # Install to system
sqlite3 --version # → Verify 3.50.100 (Check installed version)