|
1 | 1 | # Django on Vercel
|
2 | 2 |
|
3 |
| -A Simple Starter Template which helps to Deploy a **Django Project on Vercel** as a **Serverless Function** . |
4 |
| - |
5 |
| -This App is Configured with Postgres as the Choice of Database. |
6 |
| - |
7 |
| -- [x] Configured with Static Files in Production. |
8 |
| -- [x] Compatable with Postgres/MySQL DB. |
9 |
| - |
10 |
| -```sh |
11 |
| -ls |
12 |
| - build.sh # Build Script for Vercel |
13 |
| - manage.py |
14 |
| - poetry.lock # Lock All Dependency |
15 |
| - pyproject.toml # Package Manager |
16 |
| - pyvenv.cfg |
17 |
| - README.md |
18 |
| - requirements.txt # Python Requirements |
19 |
| - static # Add Your Static (Empty on Purpose) |
20 |
| - templates # Django Templates |
21 |
| - backend # Django Project Root |
22 |
| - vercel.json # Vercel Configuration |
| 3 | +A simple starter template to **deploy a Django project on Vercel** as a **serverless function**. |
| 4 | + |
| 5 | +This app is pre-configured to use **PostgreSQL** as the database. It also includes: |
| 6 | + |
| 7 | +- ✅ Static file support for production |
| 8 | +- ✅ Compatibility with PostgreSQL and MySQL |
| 9 | + |
| 10 | +## Requirements |
| 11 | + |
| 12 | +- Python 3.12 or above |
| 13 | +- Git |
| 14 | +- [uv](https://github.com/astral-sh/uv) (optional, for fast dependency management) |
| 15 | + |
| 16 | +## Getting Started (Local Development) |
| 17 | + |
| 18 | +### 1. Clone the Repository |
| 19 | + |
| 20 | +```bash |
| 21 | +mkdir -p ~/Dev/django-vercel |
| 22 | +cd ~/Dev/django-vercel |
| 23 | +git clone https://github.com/arvind-4/django-on-vercel.git . |
| 24 | +``` |
| 25 | + |
| 26 | +### 2. Create a Virtual Environment |
| 27 | + |
| 28 | +#### Option A: Using [uv](https://github.com/astral-sh/uv) |
| 29 | + |
| 30 | +```bash |
| 31 | +uv venv |
| 32 | +uv sync |
23 | 33 | ```
|
24 | 34 |
|
25 |
| -## Get & Running on your Local Machine |
| 35 | +#### Option B: Using `venv` and `pip` |
26 | 36 |
|
27 |
| -- Clone the **Repo** |
28 |
| -```sh |
29 |
| -cd ~/Dev/ |
30 |
| -mkdir django_vercel |
31 |
| -cd django_vercel |
32 |
| -git clone https://github.com/Arvind-4/Django-with-Vercel.git . |
| 37 | +```bash |
| 38 | +python3.12 -m venv venv |
| 39 | +source venv/bin/activate |
| 40 | +pip install -r requirements.txt -r requirements-dev.txt |
33 | 41 | ```
|
34 |
| -- Create a **Virtual Environment** for **Python** |
35 |
| - - using **Poetry** |
36 |
| - ```python |
37 |
| - virtualenv --python=python3.9 . |
38 |
| - source bin/activate |
39 |
| - poetry install |
40 |
| - ``` |
41 |
| - - using **Virtualenv** |
42 |
| - ```python |
43 |
| - virtualenv --python=python3.9 . |
44 |
| - source bin/activate |
45 |
| - pip install -r requirements.txt |
46 |
| - ``` |
47 |
| - |
48 |
| -- Run Locally |
49 |
| -```python |
50 |
| -cd ~/Dev/django_vercel |
| 42 | + |
| 43 | +### 3. Set Up Environment Variables |
| 44 | + |
| 45 | +```bash |
| 46 | +cp .env.sample .env |
| 47 | +``` |
| 48 | + |
| 49 | +> Make sure to update `.env` with your actual credentials and settings. |
| 50 | +
|
| 51 | +### 4. Run the Server Locally |
| 52 | + |
| 53 | +```bash |
51 | 54 | python manage.py runserver
|
52 | 55 | ```
|
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## Notes |
| 60 | + |
| 61 | +- This setup is optimized for deployment on **Vercel** as a serverless backend. |
| 62 | +- Ensure your database settings in `.env` are correctly configured before deploying. |
0 commit comments