Skip to content

Commit c73038d

Browse files
authored
Merge pull request #307 from DefangLabs/more-django-fixes
More fixes for Django Postgres sample
2 parents 3547721 + 77ce689 commit c73038d

File tree

9 files changed

+30
-198
lines changed

9 files changed

+30
-198
lines changed

.github/workflows/deploy.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ jobs:
1818
uses: actions/checkout@v4
1919

2020
- name: Deploy
21-
uses: DefangLabs/defang-github-action@v1.1.0
21+
uses: DefangLabs/defang-github-action@v1.2.0
22+
with:
23+
config-env-vars: POSTGRES_PASSWORD SECRET_KEY ALLOWED_HOSTS
24+
env:
25+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
26+
SECRET_KEY: ${{ secrets.SECRET_KEY }}
27+
ALLOWED_HOSTS: ${{ secrets.ALLOWED_HOSTS }}

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
This template is a customer relationship management list project developed using Python Django framework, offering a starting point to help you quickly build your customer management system. We use PostgreSQL as the database. We have prepared all the essential files for deployment. By spending less than 10 minutes setting up the environment, as detailed in the prerequisites, and executing the commands in our step-by-step guide, your website will be ready to go live to the world!
66

7-
> [!NOTE]
8-
This sample showcases how you could deploy a full-stack application with Defang and Django. However, it deploys Postgres as a Defang service. Defang [services](https://12factor.net/processes) are ephemeral and should not be used to run stateful workloads in production as they will be reset on every deployment. For production use cases you should use a managed database like RDS, Aiven, or others. If you stick to Django's default SQLite database, your stored data will be lost on every deployment, and in some other situations. In the future, Defang will help you provision and connect to managed databases.
9-
107
## Prerequisites
118

129
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
@@ -28,10 +25,29 @@ For this sample, you will need to provide the following [configuration](https://
2825
> 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.
2926
3027
### `POSTGRES_PASSWORD`
28+
29+
The password for the PostgreSQL database.
30+
3131
```bash
3232
defang config set POSTGRES_PASSWORD
3333
```
3434

35+
### `SECRET_KEY`
36+
37+
The secret key is used to secure the Django application.
38+
39+
```bash
40+
defang config set SECRET_KEY
41+
```
42+
43+
### `ALLOWED_HOSTS`
44+
45+
The allowed hosts for the Django application. (i.e. the domain your app runs on)
46+
47+
```bash
48+
defang config set ALLOWED_HOSTS
49+
```
50+
3551
## Deployment
3652

3753
> [!NOTE]

app/crm_platform/__init__.py

Whitespace-only changes.

app/crm_platform/asgi.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/crm_platform/settings.py

Lines changed: 0 additions & 139 deletions
This file was deleted.

app/crm_platform/urls.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/crm_platform/wsgi.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

compose.dev.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ services:
1717
- POSTGRES_USER=django
1818
- POSTGRES_DB=django
1919
- POSTGRES_PASSWORD=password
20+
- SECRET_KEY=django-insecure-^0jq%7b(%aj$j@n0_$gk@#73&z#t%4o#klquddg1e1hdal^9!s
21+
- ALLOWED_HOSTS=*
2022
volumes:
2123
- "./app:/code"
2224
command: python manage.py migrate

compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ services:
2727
- POSTGRES_USER=django
2828
- POSTGRES_DB=django
2929
- POSTGRES_PASSWORD
30+
- SECRET_KEY
31+
- ALLOWED_HOSTS
3032
depends_on:
3133
- db

0 commit comments

Comments
 (0)