https://github.com/nullstone-io/django-quickstart
Python Django Quickstart for Nullstone
https://github.com/nullstone-io/django-quickstart
Last synced: 10 months ago
JSON representation
Python Django Quickstart for Nullstone
- Host: GitHub
- URL: https://github.com/nullstone-io/django-quickstart
- Owner: nullstone-io
- License: mit
- Created: 2022-05-11T00:57:43.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-17T15:26:54.000Z (almost 3 years ago)
- Last Synced: 2025-05-06T08:58:40.259Z (about 1 year ago)
- Language: Python
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Django Quickstart
This is a Python Django Quickstart for [Nullstone](https://nullstone.io).
This is based off the official [Writing your first Django app](https://docs.djangoproject.com/en/4.0/intro/tutorial01/) 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
```shell
nullstone up --wait --block= --env=
```
4. Build, push, and deploy
```shell
docker build -t django-quickstart .
nullstone launch --source=django-quickstart --app= --env=
```
## 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
```shell
docker compose up
```
Visit [http://localhost:9000](http://localhost:9000).
### Dev Server
```shell
poetry run ./manage.py runserver
```
Visit [http://localhost:8000](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`.
```python
asgiref ~= 3.5.1
django ~= 4.0.4
sqlparse ~= 0.4.2
tzdata ~= 2022.1
```
4. Configure `settings.py` with `DJANGO_DEBUG`
```python
# DEBUG = True
DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False'
```
5. Configure `settings.py` with `SECRET_KEY`
```python
SECRET_KEY = os.environ.get('SECRET_KEY', default='default-key')
```
6. Add `ALLOWED_HOSTS` from Nullstone.
```python
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)
```
7. Add private IP address into `ALLOWED_HOSTS`.
```python
ECS_PRIVATE_IPS = os.environ.get('ECS_PRIVATE_IPS')
if ECS_PRIVATE_IPS:
ALLOWED_HOSTS.append(ECS_PRIVATE_IPS)
```