Skip to content

Django Hello World

Use Django 4 on Vercel with Serverless Functions using the Python Runtime.

Framework
Use Case
CSS
Publisher ▲ Vercel

Django + Vercel

This example shows how to use Django 4 on Vercel with Serverless Functions using the Python Runtime.

Demo

https://django-template.vercel.app/

How it Works

Our Django application, example is configured as an installed application in vercel_app/settings.py:

# vercel_app/settings.py
INSTALLED_APPS = [
    # ...
    'example',
]

There is a single view which renders the current time in example/views.py:

# example/views.py
from datetime import datetime

from django.http import HttpResponse


def index(request):
    now = datetime.now()
    html = f'''
    <html>
        <body>
            <h1>Hello from Vercel!</h1>
            <p>The current time is { now }.</p>
        </body>
    </html>
    '''
    return HttpResponse(html)

This view is exposed a URL through example/urls.py:

# example/urls.py
from django.urls import path

from example.views import index


urlpatterns = [
    path('', index),
]

Finally, it's made accessible to the Django server inside vercel_app/urls.py:

# vercel_app/urls.py
from django.urls import path, include

urlpatterns = [
    ...
    path('', include('example.urls')),
]

This example uses the Web Server Gateway Interface (WSGI) with Django to enable handling requests on Vercel with Serverless Functions.

Running Locally

python manage.py runserver

Your Django application is now available at http://localhost:8000.

One-Click Deploy

Deploy the example using Vercel:

Django Hello World

Use Django 4 on Vercel with Serverless Functions using the Python Runtime.

Framework
Use Case
CSS
Publisher ▲ Vercel

Django + Vercel

This example shows how to use Django 4 on Vercel with Serverless Functions using the Python Runtime.

Demo

https://django-template.vercel.app/

How it Works

Our Django application, example is configured as an installed application in vercel_app/settings.py:

# vercel_app/settings.py
INSTALLED_APPS = [
    # ...
    'example',
]

There is a single view which renders the current time in example/views.py:

# example/views.py
from datetime import datetime

from django.http import HttpResponse


def index(request):
    now = datetime.now()
    html = f'''
    <html>
        <body>
            <h1>Hello from Vercel!</h1>
            <p>The current time is { now }.</p>
        </body>
    </html>
    '''
    return HttpResponse(html)

This view is exposed a URL through example/urls.py:

# example/urls.py
from django.urls import path

from example.views import index


urlpatterns = [
    path('', index),
]

Finally, it's made accessible to the Django server inside vercel_app/urls.py:

# vercel_app/urls.py
from django.urls import path, include

urlpatterns = [
    ...
    path('', include('example.urls')),
]

This example uses the Web Server Gateway Interface (WSGI) with Django to enable handling requests on Vercel with Serverless Functions.

Running Locally

python manage.py runserver

Your Django application is now available at http://localhost:8000.

One-Click Deploy

Deploy the example using Vercel:

Unleash New Possibilities

Deploy your app on Vercel and unlock its full potential

Try Vercel Free