Compare commits
26 Commits
026bce1f16
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e0675c8684 | |||
| 4b18769137 | |||
| 90b7bb0dee | |||
| 8cfe5c6f9b | |||
| 9397c2d4f2 | |||
| 313702f9fe | |||
|
|
49199b7184 | ||
|
|
c17e3e85f2 | ||
|
|
be54afa093 | ||
|
|
fd5414bd5a | ||
|
|
6b635955eb | ||
|
|
0610053a3e | ||
| 79560c5835 | |||
| c1aa69dd8b | |||
| d17b2f0a2a | |||
| 41a61fb318 | |||
| cba945375c | |||
|
|
1c545638b9 | ||
|
|
5fa195a0dc | ||
|
|
f8dc8fc684 | ||
| df587931b5 | |||
|
|
01ea42b64a | ||
|
|
fe6c0df123 | ||
| 357c81ff08 | |||
|
|
26c6f46531 | ||
|
|
13a317d3df |
@@ -1,11 +1,12 @@
|
|||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
command: python -Wa manage.py test --noinput --parallel
|
command: python manage.py check --deploy
|
||||||
restart: "no"
|
restart: "no"
|
||||||
env_file:
|
env_file:
|
||||||
- path: .env.template
|
- path: .env.template
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
||||||
db:
|
db:
|
||||||
env_file:
|
env_file:
|
||||||
- path: .env.template
|
- path: .env.template
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
command: gunicorn -b 0.0.0.0:8000 website.wsgi:application
|
command: gunicorn --capture-output --enable-stdio-inheritance -b 0.0.0.0:8000 website.wsgi:application
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/src
|
- ./src:/src
|
||||||
env_file:
|
env_file:
|
||||||
14
.docker-compose-files/compose.test.yaml
Normal file
14
.docker-compose-files/compose.test.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
command: python manage.py check --deploy; python -Wa manage.py test --noinput --parallel
|
||||||
|
restart: "no"
|
||||||
|
env_file:
|
||||||
|
- path: .env.template
|
||||||
|
required: true
|
||||||
|
|
||||||
|
|
||||||
|
db:
|
||||||
|
env_file:
|
||||||
|
- path: .env.template
|
||||||
|
required: true
|
||||||
|
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
|
#NGINX
|
||||||
|
NGINX_HOSTNAME=localhost
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
DJANGO_SETTINGS_MODULE=website.settings
|
DJANGO_SETTINGS_MODULE=website.settings
|
||||||
DJANGO_SECRET_KEY=CWHZCAZBNV57tDkwGHJwTUu3PCSnGG45
|
DJANGO_SECRET_KEY=CWHZCAZBNV57tDkwGHJwTUu3PCSnGG45
|
||||||
DEBUG=TRUE
|
DEBUG=TRUE
|
||||||
ALLOWED_HOSTS=localhost
|
#ALLOWED_HOSTS=localhost
|
||||||
|
|
||||||
# Database (PostgreSQL)
|
# Database (PostgreSQL)
|
||||||
POSTGRES_USER=test_user
|
POSTGRES_USER=test_user
|
||||||
@@ -14,4 +17,4 @@ POSTGRES_DB=test_db
|
|||||||
|
|
||||||
# Gunicorn
|
# Gunicorn
|
||||||
GUNICORN_WORKERS=3
|
GUNICORN_WORKERS=3
|
||||||
GUNICORN_TIMEOUT=120
|
GUNICORN_TIMEOUT=120
|
||||||
@@ -3,7 +3,7 @@ run-name: ${{ gitea.actor }}
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- pre-prod
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -15,3 +15,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: make test
|
run: make test
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: make prod
|
||||||
@@ -31,5 +31,8 @@ jobs:
|
|||||||
echo "Building containers..."
|
echo "Building containers..."
|
||||||
make prod
|
make prod
|
||||||
|
|
||||||
|
echo "Running Django deploy check"
|
||||||
|
docker compose run --rm web python manage.py check --deploy
|
||||||
|
|
||||||
echo "Deployment complete."
|
echo "Deployment complete."
|
||||||
EOF
|
EOF
|
||||||
17
.gitea/workflows/test.yaml
Normal file
17
.gitea/workflows/test.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: Gitea Test.
|
||||||
|
run-name: ${{ gitea.actor }}
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- pre-prod
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
run: make test
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -175,3 +175,7 @@ cython_debug/
|
|||||||
# PyPI configuration file
|
# PyPI configuration file
|
||||||
.pypirc
|
.pypirc
|
||||||
|
|
||||||
|
# gunicon webserver
|
||||||
|
gunicorn.ctl
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
.nginx/.conf
Normal file
3
.nginx/.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
events {}
|
||||||
|
|
||||||
|
http {}
|
||||||
49
.nginx/.templates/nginx.conf.template
Normal file
49
.nginx/.templates/nginx.conf.template
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
server {
|
||||||
|
listen ${NGINX_PORT};
|
||||||
|
server_name ${NGINX_HOSTNAME};
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /app/static/;
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media/ {
|
||||||
|
alias /app/media;
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://web:8000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen ${NGINX_SSL_PORT};
|
||||||
|
server_name ${NGINX_HOSTNAME};
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /app/static/;
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media/ {
|
||||||
|
alias /app/media;
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://web:8000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Makefile
22
Makefile
@@ -1,10 +1,26 @@
|
|||||||
prod:
|
prod:
|
||||||
docker compose down
|
docker compose down
|
||||||
docker compose -f ./compose.yaml -f ./compose.prod.yaml up -d --build
|
docker compose --env-file .env -f ./compose.yaml -f ./.docker-compose-files/compose.prod.yaml up -d --build
|
||||||
|
docker exec quatsh-website-web-1 python manage.py collectstatic --noinput
|
||||||
|
docker exec quatsh-website-web-1 python manage.py check --deploy
|
||||||
|
docker exec quatsh-website-web-1 python manage.py migrate
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
docker compose down
|
docker compose down
|
||||||
docker compose -f ./compose.yaml -f ./compose.dev.yaml up --build
|
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.dev.yaml up --build -d
|
||||||
|
docker exec quatsh-website-web-1 python manage.py collectstatic --noinput
|
||||||
|
docker exec -it quatsh-website-web-1 sh
|
||||||
|
|
||||||
|
dev_restart:
|
||||||
|
docker compose down
|
||||||
|
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.dev.yaml up -d
|
||||||
|
docker exec -it quatsh-website-web-1 sh
|
||||||
|
|
||||||
|
dev_restart_with_logs:
|
||||||
|
docker compose down
|
||||||
|
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.dev.yaml up
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
docker compose --env-file .env.template -f ./compose.yaml -f ./compose.test.yaml up --build --abort-on-container-exit --exit-code-from web
|
docker compose --env-file .env.template -f ./compose.yaml -f ./.docker-compose-files/compose.test.yaml up --build --abort-on-container-exit --exit-code-from web
|
||||||
|
|
||||||
|
|||||||
45
README.md
45
README.md
@@ -1,44 +1,65 @@
|
|||||||
# Quatsh-Website
|
# Quatsh-Website
|
||||||
|
|
||||||
## Requirements:
|
## Requirements
|
||||||
|
|
||||||
### Install make
|
### Install make
|
||||||
Running this requires the use of "make" and docker.\
|
|
||||||
|
Running this requires the use of "make" and docker.
|
||||||
|
|
||||||
"make" tends to come pre-installed on linux but not on Windows, to install it on Windows I recommend using Chocolatey as follows: \
|
"make" tends to come pre-installed on linux but not on Windows, to install it on Windows I recommend using Chocolatey as follows: \
|
||||||
|
|
||||||
```
|
```
|
||||||
choco install make
|
choco install make
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install docker
|
### Install docker
|
||||||
https://docs.docker.com/get-started/get-docker/
|
|
||||||
|
<https://docs.docker.com/get-started/get-docker/>
|
||||||
|
|
||||||
## Running for the first time
|
## Running for the first time
|
||||||
|
|
||||||
### Env
|
### Env
|
||||||
|
|
||||||
Before running the container environment has to be setup first, so first run:
|
Before running the container environment has to be setup first, so first run:
|
||||||
|
|
||||||
```
|
```
|
||||||
cp .env.template .env
|
cp .env.template .env
|
||||||
```
|
```
|
||||||
Then make any nessecary adjustments to the .env file.
|
|
||||||
|
|
||||||
### Running the website:
|
Then make any changes to the .env file.
|
||||||
|
|
||||||
|
### Running the website
|
||||||
|
|
||||||
To run the website 3 options have been provided
|
To run the website 3 options have been provided
|
||||||
#### Development:
|
|
||||||
|
#### Development
|
||||||
|
|
||||||
For development purposes only as the src folder has been mounted in the container to allow for the making of changes without rebuilding the entire image.
|
For development purposes only as the src folder has been mounted in the container to allow for the making of changes without rebuilding the entire image.
|
||||||
```
|
Properly utilising this also requires the DEBUG environment variable to be set to TRUE.
|
||||||
|
|
||||||
|
```shell
|
||||||
make dev
|
make dev
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Testing
|
#### Testing
|
||||||
|
|
||||||
Runs the testing environment and exits.
|
Runs the testing environment and exits.
|
||||||
```
|
|
||||||
|
```shell
|
||||||
make test
|
make test
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Production
|
#### Production
|
||||||
|
|
||||||
Using `make prod` is identical but preferred here.
|
Using `make prod` is identical but preferred here.
|
||||||
```
|
|
||||||
|
```shell
|
||||||
make prod
|
make prod
|
||||||
# or
|
```
|
||||||
|
|
||||||
|
Or
|
||||||
|
|
||||||
|
```shell
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
32
compose.yaml
32
compose.yaml
@@ -1,21 +1,26 @@
|
|||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
command: gunicorn --proxy-protocol auto --proxy-allow-from 10.10.50.11 website.wsgi:application
|
command: gunicorn website.wsgi:application
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
ports:
|
|
||||||
- 8000:8000
|
|
||||||
environment:
|
environment:
|
||||||
|
ALLOWED_HOSTS: ${NGINX_HOSTNAME}
|
||||||
PYTHONDONTWRITEBYTECODE: 1
|
PYTHONDONTWRITEBYTECODE: 1
|
||||||
PYTHONUNBUFFERED: 1
|
PYTHONUNBUFFERED: 1
|
||||||
DJANGO_SETTINGS_MODULE: ${DJANGO_SETTINGS_MODULE}
|
DJANGO_SETTINGS_MODULE: ${DJANGO_SETTINGS_MODULE}
|
||||||
|
VIRTUAL_HOST: localhost
|
||||||
|
#VIRTUAL_PORT: 8000
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- static_volume:/app/static
|
||||||
|
- media_volume:/app/media
|
||||||
|
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: postgres:18
|
image: postgres:18
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DBNAME}
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
@@ -30,6 +35,23 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
|
|
||||||
|
proxy:
|
||||||
|
image: nginx:stable
|
||||||
|
volumes:
|
||||||
|
- ./.nginx/.templates:/etc/nginx/templates
|
||||||
|
- static_volume:/app/static:ro
|
||||||
|
- media_volume:/app/media:ro
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
environment:
|
||||||
|
- NGINX_HOSTNAME=${NGINX_HOSTNAME}
|
||||||
|
- NGINX_PORT=80
|
||||||
|
- NGINX_SSL_PORT=443
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
|
||||||
test:
|
test:
|
||||||
build: .
|
build: .
|
||||||
command: python manage.py test
|
command: python manage.py test
|
||||||
@@ -41,3 +63,5 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
static_volume:
|
||||||
|
media_volume:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
Django==6.0.3
|
Django==6.0.3
|
||||||
gunicorn==25.1.0
|
gunicorn==25.1.0
|
||||||
psycopg [binary] ==3.3.3
|
psycopg [binary] ==3.3.3
|
||||||
|
django-browser-reload
|
||||||
|
django-watchfiles
|
||||||
|
|||||||
0
src/polls/__init__.py
Normal file
0
src/polls/__init__.py
Normal file
7
src/polls/admin.py
Normal file
7
src/polls/admin.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
|
|
||||||
|
from .models import Question
|
||||||
|
|
||||||
|
admin.site.register(Question)
|
||||||
5
src/polls/apps.py
Normal file
5
src/polls/apps.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class PollsConfig(AppConfig):
|
||||||
|
name = 'polls'
|
||||||
32
src/polls/migrations/0001_initial.py
Normal file
32
src/polls/migrations/0001_initial.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Generated by Django 6.0.3 on 2026-03-25 14:26
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Question',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('question_text', models.CharField(max_length=200)),
|
||||||
|
('pub_date', models.DateTimeField(verbose_name='date published')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Choice',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('choice_text', models.CharField(max_length=200)),
|
||||||
|
('votes', models.IntegerField(default=0)),
|
||||||
|
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.question')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
0
src/polls/migrations/__init__.py
Normal file
0
src/polls/migrations/__init__.py
Normal file
20
src/polls/models.py
Normal file
20
src/polls/models.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
|
||||||
|
|
||||||
|
class Question(models.Model):
|
||||||
|
question_text = models.CharField(max_length=200)
|
||||||
|
pub_date = models.DateTimeField("date published")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.question_text
|
||||||
|
|
||||||
|
|
||||||
|
class Choice(models.Model):
|
||||||
|
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
||||||
|
choice_text = models.CharField(max_length=200)
|
||||||
|
votes = models.IntegerField(default=0)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.choice_text
|
||||||
11
src/polls/templates/polls/detail.html
Normal file
11
src/polls/templates/polls/detail.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-US">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>My test page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hey This is a test of watchfiles + browser reload!</h1>
|
||||||
|
{{ question }}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
19
src/polls/templates/polls/index.html
Normal file
19
src/polls/templates/polls/index.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-US">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>My test page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% if latest_question_list %}
|
||||||
|
<ul>
|
||||||
|
{% for question in latest_question_list %}
|
||||||
|
<li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No polls are available.</p>
|
||||||
|
{% endif %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
3
src/polls/tests.py
Normal file
3
src/polls/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
14
src/polls/urls.py
Normal file
14
src/polls/urls.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
# ex: /polls/
|
||||||
|
path("", views.index, name="index"),
|
||||||
|
# ex: /polls/5/
|
||||||
|
path("<int:question_id>/", views.detail, name="detail"),
|
||||||
|
# ex: /polls/5/results/
|
||||||
|
path("<int:question_id>/results/", views.results, name="results"),
|
||||||
|
# ex: /polls/5/vote/
|
||||||
|
path("<int:question_id>/vote/", views.vote, name="vote"),
|
||||||
|
]
|
||||||
24
src/polls/views.py
Normal file
24
src/polls/views.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from django.http import HttpResponse, Http404
|
||||||
|
from django.shortcuts import get_object_or_404, render
|
||||||
|
|
||||||
|
from .models import Question
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
latest_question_list = Question.objects.order_by("-pub_date")[:5]
|
||||||
|
context = {"latest_question_list": latest_question_list}
|
||||||
|
return render(request, "polls/index.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
def detail(request, question_id):
|
||||||
|
question = get_object_or_404(Question, pk=question_id)
|
||||||
|
return render(request, "polls/detail.html", {"question": question})
|
||||||
|
|
||||||
|
|
||||||
|
def results(request, question_id):
|
||||||
|
response = "You're looking at the results of question %s."
|
||||||
|
return HttpResponse(response % question_id)
|
||||||
|
|
||||||
|
|
||||||
|
def vote(request, question_id):
|
||||||
|
return HttpResponse("You're voting on question %s." % question_id)
|
||||||
@@ -21,24 +21,27 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = "django-insecure-c$q7wdq+u@ow74wp!&zzkxdylkueu)(+34e%!e0du&bjwoqz9z"
|
SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = bool(os.getenv("DEBUG"))
|
DEBUG = os.getenv("DEBUG") == "TRUE"
|
||||||
|
|
||||||
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS").split(",")
|
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "127.0.0.1").split(",")
|
||||||
|
|
||||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
"polls.apps.PollsConfig",
|
||||||
"django.contrib.admin",
|
"django.contrib.admin",
|
||||||
"django.contrib.auth",
|
"django.contrib.auth",
|
||||||
"django.contrib.contenttypes",
|
"django.contrib.contenttypes",
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
|
"django_browser_reload",
|
||||||
|
"django_watchfiles",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -49,6 +52,7 @@ MIDDLEWARE = [
|
|||||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||||
"django.contrib.messages.middleware.MessageMiddleware",
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
|
"django_browser_reload.middleware.BrowserReloadMiddleware",
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = "website.urls"
|
ROOT_URLCONF = "website.urls"
|
||||||
@@ -77,7 +81,7 @@ WSGI_APPLICATION = "website.wsgi.application"
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.postgresql",
|
"ENGINE": "django.db.backends.postgresql",
|
||||||
"DBNAME": os.getenv("POSTGRES_DBNAME"),
|
"NAME": os.getenv("POSTGRES_DBNAME"),
|
||||||
"USER": os.getenv("POSTGRES_USER"),
|
"USER": os.getenv("POSTGRES_USER"),
|
||||||
"PASSWORD": os.getenv("POSTGRES_PASSWORD"),
|
"PASSWORD": os.getenv("POSTGRES_PASSWORD"),
|
||||||
"HOST": os.getenv("POSTGRES_HOST"),
|
"HOST": os.getenv("POSTGRES_HOST"),
|
||||||
@@ -110,7 +114,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
|
|
||||||
LANGUAGE_CODE = "en-us"
|
LANGUAGE_CODE = "en-us"
|
||||||
|
|
||||||
TIME_ZONE = "UTC"
|
TIME_ZONE = "Europe/Amsterdam"
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
@@ -120,4 +124,5 @@ USE_TZ = True
|
|||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_ROOT = "/app/static/"
|
||||||
STATIC_URL = "static/"
|
STATIC_URL = "static/"
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path("__reload__/", include("django_browser_reload.urls")),
|
||||||
|
path("polls/", include("polls.urls")),
|
||||||
|
path("admin/", admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user