Skip to content

Latest commit

 

History

History
66 lines (41 loc) · 2.79 KB

README.md

File metadata and controls

66 lines (41 loc) · 2.79 KB

Django

1-click-deploy

This sample is a simple Django to-do app that uses SQLite as the database, which will be reset every time you deploy. It is not production-ready. For production use cases, you should check out the Django + Postgres sample.

The app includes a management command which is run on startup to create a superuser with the username admin and password admin. This means you can login to the admin interface at /admin/ and see the Django admin interface without any additional steps. The example_app is already registered and the Todo model is already set up to be managed in the admin interface.

The Dockerfile and compose files are already set up for you and are ready to be deployed. Serving is done using Gunicorn and uses WhiteNoise for static files. The CSRF_TRUSTED_ORIGINS setting is configured to allow the app to run on a defang.dev subdomain.

Prerequisites

  1. Download Defang CLI
  2. (Optional) If you are using Defang BYOC authenticate with your cloud provider account
  3. (Optional for local development) Docker CLI

Development

To run the application locally, you can use the following command:

docker compose up --build

Configuration

For this sample, you will not need to provide configuration.

If you wish to provide configuration, see below for an example of setting a configuration for a value named API_KEY.

defang config set API_KEY

Deployment

Note

Download Defang CLI

Defang Playground

Deploy your application to the Defang Playground by opening up your terminal and typing:

defang compose up

BYOC (AWS)

If you want to deploy to your own cloud account, you can use Defang BYOC:

  1. Authenticate your AWS account, and check that you have properly set your environment variables like AWS_PROFILE, AWS_REGION, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY.
  2. Make sure to update the CSRF_TRUSTED_ORIGINS setting in the settings.py file to include an appropriate domain.
  3. Run in a terminal that has access to your AWS environment variables:
    defang --provider=aws compose up

Title: Django

Short Description: A simple Django app that uses SQLite as the database.

Tags: Django, SQLite, Python

Languages: python