
This example shows how to use Django 4 on Vercel with Serverless Functions using the Python Runtime.
https://django-template.vercel.app/
Our Django application, example is configured as an installed application in api/settings.py:
We allow "*.vercel.app" subdomains in ALLOWED_HOSTS, in addition to 127.0.0.1:
The wsgi module must use a public variable named app to expose the WSGI application:
The corresponding WSGI_APPLICATION setting is configured to use the app variable from the api.wsgi module:
There is a single view which renders the current time in example/views.py:
This view is exposed a URL through example/urls.py:
Finally, it's made accessible to the Django server inside api/urls.py:
This example uses the Web Server Gateway Interface (WSGI) with Django to enable handling requests on Vercel with Serverless Functions.
Your Django application is now available at http://localhost:8000.
Deploy the example using Vercel: