This is a simple example of how to run Django on Defang. It is a simple Todo app that uses SQLite as the database.
This sample is a simple Django 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.
- A Dockerfile to describe the basic image of your applications.
- A docker-compose file to define and run multi-container Docker applications.
- A .dockerignore file to comply with the size limit (10MB).
- Download Defang CLI
- If you are using Defang BYOC, make sure you have properly authenticated your AWS account
Plus, make sure that you have properly set your environment variables like
AWS_PROFILE
,AWS_REGION
,AWS_ACCESS_KEY_ID
, andAWS_SECRET_ACCESS_KEY
.
- (optional) If you are using Defang BYOC, make sure to update the
CSRF_TRUSTED_ORIGINS
setting in thesettings.py
file to include an appropriate domain. - Open the terminal and type
defang login
- Type
defang compose up
in the CLI - Now your application will be launched
Title: Django
Short Description: A simple Django app that uses SQLite as the database
Tags: Django, SQLite, Python
Languages: python