About Pinged Pages and HEAD Request

If you use UptimeRobot, Oh Dear, PingPing, or other service to monitor your website's uptime, make sure to handle the HEAD requests for the pinged page early in the view, so that you don't load any unnecessary queries and don't render the templates for it:

from django.shortcuts import render
from django.http import HttpResponse

def home(request, *args, **kwargs):
    if request.method == "HEAD":
        return HttpResponse()
    context = {...}
    return render(request, "startpage/index.html", context)

Tips and Tricks Dev Ops Development Django 5.x Django 4.2 Django 3.2