This sample demonstrates how to get Django Channels up and running with Redis and Postgres both managed by Defang. It demonstrates how to do this with a simple chat application.
- Download Defang CLI
- (Optional) If you are using Defang BYOC authenticated with your AWS account
- (Optional for local development) Docker CLI
To run the application locally, you can use the following command:
docker compose -f compose.dev.yaml up
This will start the Django server, Redis, and Postgres and mounts your Django app so you get live reloading. You can access the Django server at http://localhost:8000
.
For this sample, you will need to provide the following configuration. 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.
The secret key for your Django application. You can generate a new one by running python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
. A default, insecure key is used if this is not set, but you should set it for a production deployment.
The password for your Postgres database. You need to set this before deploying for the first time.
- Open the terminal and type
defang login
- Use the
defang config
command to setup environment variables. - Type
defang compose up
in the CLI. - Your app will be running within a few minutes.
Title: Django Channels & Redis & Postgres
Short Description: A basic configuration of Django Channels with Redis and Postgres demonstrating a simple chat application.
Tags: Django, Channels, Redis, Postgres, Chat, Application
Languages: Python