Skip to content

Commit e8878c8

Browse files
authored
[django] Document setting up the secret key (#1455)
1 parent 11bdb29 commit e8878c8

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

python/django-notes/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ A simple note-taking app built with Django, demonstrating server-side rendering,
1919

2020
https://django-notes-example.vercel.app/
2121

22+
## Setting the Secret Key
23+
24+
Django requires a secret key for cryptographic signing to be set in the `DJANGO_SECRET` environment variable. This can be set in the web interface, or by running:
25+
26+
```bash
27+
uv run python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())' | vercel env add -y DJANGO_SECRET prod
28+
```
29+
2230
## How it Works
2331

2432
This example uses Django's ORM, templates, and `staticfiles` app, served via WSGI on Vercel. The database defaults to SQLite locally and switches to Postgres when `DATABASE_URL` is set — Vercel automatically provisions this environment variable when you add a Postgres database. You can add a database during project import or later from the Storage tab.

python/django-rest-framework/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ A minimal [Django REST Framework](https://www.django-rest-framework.org/) API ru
1818

1919
https://django-rest-framework-example.vercel.app/api/time/
2020

21+
## Setting the Secret Key
22+
23+
Django requires a secret key for cryptographic signing to be set in the `DJANGO_SECRET` environment variable. This can be set in the web interface, or by running:
24+
25+
```bash
26+
uv run python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())' | vercel env add -y DJANGO_SECRET prod
27+
```
28+
2129
## How it Works
2230

2331
A single DRF view in `api/views.py` returns the current UTC time as JSON:

python/django/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ This example shows how to use Django on Vercel with Serverless Functions using t
1818

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

21+
## Setting the Secret Key
22+
23+
Django requires a secret key for cryptographic signing to be set in the `DJANGO_SECRET` environment variable. This can be set in the web interface, or by running:
24+
25+
```bash
26+
uv run python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())' | vercel env add -y DJANGO_SECRET prod
27+
```
28+
2129
## How it Works
2230

2331
Vercel detects Django's `manage.py` and uses that to find the WSGI entrypoint and the configuration for static files.

0 commit comments

Comments
 (0)