|
| 1 | +# Django Celery |
| 2 | + |
| 3 | +[](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-django-celery-template%26template_owner%3DDefangSamples) |
| 4 | + |
| 5 | +This is a sample Django application that uses Celery for background tasks. It uses Postgres as the database and Redis as the message broker. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +1. Download [Defang CLI](https://github.com/DefangLabs/defang) |
| 10 | +2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account |
| 11 | +3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/) |
| 12 | + |
| 13 | +## Development |
| 14 | + |
| 15 | +To run the application locally, you can use the following command: |
| 16 | + |
| 17 | +```bash |
| 18 | +docker compose -f compose.dev.yaml up --build |
| 19 | +``` |
| 20 | + |
| 21 | +## Configuration |
| 22 | + |
| 23 | +For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration): |
| 24 | + |
| 25 | +> Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you. |
| 26 | +
|
| 27 | +### `POSTGRES_PASSWORD` |
| 28 | +The password for the Postgres database. |
| 29 | +```bash |
| 30 | +defang config set POSTGRES_PASSWORD |
| 31 | +``` |
| 32 | + |
| 33 | +### `SECRET_KEY` |
| 34 | +The [secret key](https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-SECRET_KEY) for the Django application. |
| 35 | +```bash |
| 36 | +defang config set SECRET_KEY |
| 37 | +``` |
| 38 | + |
| 39 | +## Deployment |
| 40 | + |
| 41 | +> [!NOTE] |
| 42 | +> Download [Defang CLI](https://github.com/DefangLabs/defang) |
| 43 | +
|
| 44 | +### Defang Playground |
| 45 | + |
| 46 | +Deploy your application to the Defang Playground by opening up your terminal and typing: |
| 47 | +```bash |
| 48 | +defang compose up |
| 49 | +``` |
| 50 | + |
| 51 | +### BYOC |
| 52 | + |
| 53 | +If you want to deploy to your own cloud account, you can [use Defang BYOC](https://docs.defang.io/docs/tutorials/deploy-to-your-cloud). |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +Title: Django Celery |
| 58 | + |
| 59 | +Short Description: A Django application that uses Celery for background tasks, Postgres as the database, and Redis as the message broker. |
| 60 | + |
| 61 | +Tags: Django, Celery, Postgres, Redis |
| 62 | + |
| 63 | +Languages: python, sql |
0 commit comments