Skip to content

nullstone-io/django-quickstart

Repository files navigation

Python Django Quickstart

This is a Python Django Quickstart for Nullstone. This is based off the official Writing your first Django app guide.

This quickstart is set up with:

  • Python 3.9
  • Django 4

How to launch via Nullstone

  1. Create a public web app. (Remember app-name for later)
  2. Add a subdomain. (this will add a Load Balancer capability)
  3. Provision
nullstone up --wait --block=<app-name> --env=<env-name>
  1. Build, push, and deploy
docker build -t django-quickstart .
nullstone launch --source=django-quickstart --app=<app-name> --env=<env-name>

Running locally

You can run this project locally inside Docker or using a dev server. The docker setup is configured to hot reload; you don't have to rebuild/restart the container when you change code.

Docker

docker compose up

Visit http://localhost:9000.

Dev Server

poetry run ./manage.py runserver

Visit http://localhost:8000.

Details about quickstart

  1. Install django using pip install django.
  2. Run django-admin startproject app .
  3. Add dependencies to requirements.txt.
asgiref ~= 3.5.1
django ~= 4.0.4
sqlparse ~= 0.4.2
tzdata ~= 2022.1
  1. Configure settings.py with DJANGO_DEBUG
# DEBUG = True
DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False'
  1. Configure settings.py with SECRET_KEY
SECRET_KEY = os.environ.get('SECRET_KEY', default='default-key')
  1. Add ALLOWED_HOSTS from Nullstone.
NULLSTONE_PUBLIC_HOSTS = os.environ.get('NULLSTONE_PUBLIC_HOSTS')
if NULLSTONE_PUBLIC_HOSTS:
  ALLOWED_HOSTS.append(NULLSTONE_PUBLIC_HOSTS)
NULLSTONE_PRIVATE_HOSTS = os.environ.get('NULLSTONE_PRIVATE_HOSTS')
if NULLSTONE_PRIVATE_HOSTS:
  ALLOWED_HOSTS.append(NULLSTONE_PRIVATE_HOSTS)
  1. Add private IP address into ALLOWED_HOSTS.
ECS_PRIVATE_IPS = os.environ.get('ECS_PRIVATE_IPS')
if ECS_PRIVATE_IPS:
  ALLOWED_HOSTS.append(ECS_PRIVATE_IPS)

About

Python Django Quickstart for Nullstone

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published