|
| 1 | +# Crew.ai Django Sample |
| 2 | + |
| 3 | +[](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-crew-django-redis-postgres-template%26template_owner%3DDefangSamples) |
| 4 | + |
| 5 | +This sample shows how to use Crew.ai with a Django application. It provides a simple web interface that allows users to input text and receive a summary of the text in real-time using Django Channels with a Redis broker. It uses Celery to handle the Crew.ai tasks in the background with Redis as a broker. It uses Postgres as the database for Django. |
| 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.local.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 | +### `SSL_MODE` |
| 34 | + |
| 35 | +The SSL mode for the Postgres database. |
| 36 | +```bash |
| 37 | +defang config set SSL_MODE |
| 38 | +``` |
| 39 | + |
| 40 | +### `DJANGO_SECRET_KEY` |
| 41 | + |
| 42 | +The secret key for the Django application. |
| 43 | +```bash |
| 44 | +defang config set DJANGO_SECRET_KEY |
| 45 | +``` |
| 46 | + |
| 47 | +## Deployment |
| 48 | + |
| 49 | +> [!NOTE] |
| 50 | +> Download [Defang CLI](https://github.com/DefangLabs/defang) |
| 51 | +
|
| 52 | +### Defang Playground |
| 53 | + |
| 54 | +Deploy your application to the Defang Playground by opening up your terminal and typing: |
| 55 | +```bash |
| 56 | +defang compose up |
| 57 | +``` |
| 58 | + |
| 59 | +### BYOC |
| 60 | + |
| 61 | +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). |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +Title: Crew.ai Django Sample |
| 66 | + |
| 67 | +Short Description: A sample application that uses Crew.ai to summarize text in a background task, streamed to the user in real-time. |
| 68 | + |
| 69 | +Tags: Django, Celery, Redis, Postgres, AI, ML |
| 70 | + |
| 71 | +Languages: Python |
0 commit comments