Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamyala/modal_django_example
An example of a django project deployed to modal.com
https://github.com/adamyala/modal_django_example
deployment django modal
Last synced: 3 days ago
JSON representation
An example of a django project deployed to modal.com
- Host: GitHub
- URL: https://github.com/adamyala/modal_django_example
- Owner: adamyala
- Created: 2023-01-05T19:05:22.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T01:30:46.000Z (4 months ago)
- Last Synced: 2024-11-10T03:37:00.063Z (2 months ago)
- Topics: deployment, django, modal
- Language: Python
- Homepage: https://adamyala--django-example.modal.run/admin/
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Modal django example
## Installation and local server
### Run using django tooling
```shell
# activate your python virtual environment
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
```### Run using modal tooling
```shell
modal serve config/modal_wsgi.py
```## Deployment
```shell
# activate your python virtual environment# create environment variables
# you only have to create secrets once per project
# get a db url before this step. i like elephantsql.com for free hobby dbs
modal secret create demo-secrets DATABASE_URL= SECRET_KEY=
# collect static files locally to be pushed
python manage.py collectstatic --no-input
# deploy web endpoint
modal deploy config/modal_wsgi.py
# deploy scheduled jobs
modal deploy config/modal_jobs.py
```### Modal specific files
- `config/__init__.py` initializes secrets, image, and mounts used for modal
- `config/modal_settings.py` sets remote `SECRET_KEY` variable and connects to remote postgres database
- `config/modal_wsgi.py` wsgi entry point for web endpoint
- `config/modal_jobs.py` calls django command to run scheduled jobs