Dynamic web apps
Rafeqm opened this issue · 3 comments
This is good if we just want to display TemplateView a.k.a static website. But how can we use this to create dynamic website since Django is built primarily for dynamic ones?
@Rafeqm this gives you Django running in Vercel's serverless platform (really just a wrapper around AWS Lambda). All of Django's WSGI functionality is available - e.g., you can get Django's out-of-the-box user-management and session-management working just with the addition of a database connection.
All of Django's WSGI functionality is available - e.g., you can get Django's out-of-the-box user-management and session-management working just with the addition of a database connection.
Can you please explain how that database connection work (because DATABASES
setting is empty here)? It's totally different if we deploy Django to other familiar platform like Heroku or DigitalOcean. My point is how and where Vercel store the database of a Django project?
@Rafeqm Vercel doesn't offer a database service. You could set up a database on Digital Ocean (e.g.) and then add a DATABASES
setting that points to that database - e.g.:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django-db',
'USER': 'django-db-role',
'PASSWORD': 'the password for the role',
'HOST': 'the-db-host.db.ondigitalocean.com',
'PORT': '5432',
}
}
You'll want to be mindful of security in this arrangement - it would be prudent to allowlist only Vercel's execution IPs in a firewall on Digital Ocean in an arrangement like this - in addition to other alternative authentication / connection arrangements.