I'm currently trying to deploy my Django project to Vercel, using Supabase as the PostgreSQL database provider. I have separated my settings into base.py
, development.py
, and production.py
to manage environment-specific configurations.
Problem:
When attempting to migrate the database using python manage.py migrate
, I encounter the following error:
```bash
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
```
Setup Details:
from decouple import config
import dj_database_url
from urllib.parse import urlparse
# Production-specific settings
DEBUG = True
# Parse the DATABASE_URL to extract components
url = urlparse(config('DATABASE_URL'))
# Configure your production database (example using PostgreSQL)
DATABASES = {
'default': dj_database_url.config(
default=config('DATABASE_URL')
)
}
# configure the database ENGINE to use the Postgres database
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql'
# Optional: Additional database settings
DATABASES['default']['ATOMIC_REQUESTS'] = True
# Cache configuration
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': config('UPSTASH_REDIS_REST_URL'),
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
}
}
}
# Static and media files settings for production
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
# Use proper email backend for production (e.g., SMTP)
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = config('EMAIL_PORT', default=587)
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
# Cloudinary storage for production
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'
SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_HSTS_SECONDS = 60
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_BROWSER_XSS_FILTER = True
SECURE_HSTS_PRELOAD = True
DOMAIN = "https://car-zone-dealership.vercel.app
2. Environment Setup:
DATABASE_URL
is set correctly in the .env
file and verified locally.UPSTASH_REDIS_REST_URL
, EMAIL_HOST
, EMAIL_PORT
, EMAIL_HOST_USER
, EMAIL_HOST_PASSWORD
, CLOUD_NAME
, API_KEY
, API_SECRET
) are configured in the .env
file.3. Error Screenshot:
the error message encountered during python manage.py migrate
.
Request:
I would appreciate any insights or suggestions on how to resolve this ImproperlyConfigured error and successfully migrate my Django project's database on Vercel with Supabase PostgreSQL.
Thank you in advance for your help!
I have tried to google about it and tried the answers given including using url parser to get use the connection string and get the variables but still nothing worked