Prerequisites
- A Vercel account
- A GitHub account
- A Django project
- The following Python packages:
- psycopg2-binary
- dj-database-url
- python-decouple
pip install psycopg2-binary dj-database-url python-decouple
pip freeze > requirements.txt
DATABASE_URL="{your cloud database url}"
*.env
bin/
lib/
*.sqlite3
#!/bin/bash
# Build the project
echo "Building the project..."
python3.9 -m pip install -r requirements.txt
echo "Make Migration..."
python3.9 manage.py makemigrations --noinput
python3.9 manage.py migrate --noinput
echo "Collect Static..."
python3.9 manage.py collectstatic --noinput
{
"version": 2,
"builds": [
{
"src": "backend/wsgi.py",
"use": "@vercel/python",
"config": {
"maxLambdaSize": "15mb",
"runtime": "python3.9"
}
},
{
"src": "build.sh",
"use": "@vercel/static-build",
"config": {
"distDir": "staticfiles_build"
}
}
],
"routes": [
{
"src": "/static/(.*)",
"dest": "/static/$1"
},
{
"src": "/(.*)",
"dest": "backend/wsgi.py"
}
]
}
import dj_database_url
from decouple import config
# Change the DATABASES configuration
DATABASES["default"] = dj_database_url.config()
# Add these for static files
STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / "staticfiles_build" / "static"
# Add these for media files
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
app = get_wsgi_application()
Congratulations! You've successfully deployed your Django project on Vercel. Now your project is accessible to the world.
Building engaging websites that naturally incorporate the power of artificial intelligence and other innovative technologies is where my expertise shines. I design and develop websites that effortlessly fuse creativity, intelligence, and user-centric functionality. With a harmonious blend of art and technology, my digital creations offer a seamless and captivating online experience.