added auto-reload when developing.
Some checks failed
Gitea build & Test. / tests (push) Failing after 21s
Some checks failed
Gitea build & Test. / tests (push) Failing after 21s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
services:
|
||||
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:
|
||||
- ./src:/src
|
||||
env_file:
|
||||
|
||||
10
Makefile
10
Makefile
@@ -11,6 +11,16 @@ dev:
|
||||
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:
|
||||
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
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
Django==6.0.3
|
||||
gunicorn==25.1.0
|
||||
psycopg [binary] ==3.3.3
|
||||
django-browser-reload
|
||||
django-watchfiles
|
||||
|
||||
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,5 +3,12 @@ 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"),
|
||||
]
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
|
||||
from .models import Question
|
||||
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("Hello, world. You're at the polls index.")
|
||||
latest_question_list = Question.objects.order_by("-pub_date")[:5]
|
||||
context = {"latest_question_list": latest_question_list}
|
||||
return render(request, "polls/index.html", context)
|
||||
|
||||
|
||||
# Create your views here.
|
||||
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)
|
||||
|
||||
@@ -40,6 +40,8 @@ INSTALLED_APPS = [
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"django_browser_reload",
|
||||
"django_watchfiles",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -50,6 +52,7 @@ MIDDLEWARE = [
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"django_browser_reload.middleware.BrowserReloadMiddleware",
|
||||
]
|
||||
|
||||
ROOT_URLCONF = "website.urls"
|
||||
|
||||
@@ -19,6 +19,7 @@ from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path("__reload__/", include("django_browser_reload.urls")),
|
||||
path("polls/", include("polls.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user