From 4d76891d1b76be103cc94d80a9f68d3d7d746526 Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Fri, 23 Feb 2024 04:01:36 +0100 Subject: [PATCH 1/6] preping views --- tldtest/settings.py | 2 +- tldtest/templates/index.html | 3 +++ tldtest/urls.py | 2 ++ tldtest/views.py | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tldtest/templates/index.html create mode 100644 tldtest/views.py diff --git a/tldtest/settings.py b/tldtest/settings.py index 84ba062..13f8445 100644 --- a/tldtest/settings.py +++ b/tldtest/settings.py @@ -56,7 +56,7 @@ ROOT_URLCONF = 'tldtest.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + "DIRS": [BASE_DIR / "templates"], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/tldtest/templates/index.html b/tldtest/templates/index.html new file mode 100644 index 0000000..819c632 --- /dev/null +++ b/tldtest/templates/index.html @@ -0,0 +1,3 @@ +{% block content %} +Hello World +{% endblock content %} diff --git a/tldtest/urls.py b/tldtest/urls.py index ccd3d6c..59b728b 100644 --- a/tldtest/urls.py +++ b/tldtest/urls.py @@ -15,7 +15,9 @@ Including another URLconf """ from django.contrib import admin from django.urls import path +from .views import Index urlpatterns = [ + path("", Index.as_view(), name="home"), path('admin/', admin.site.urls), ] diff --git a/tldtest/views.py b/tldtest/views.py new file mode 100644 index 0000000..0415afc --- /dev/null +++ b/tldtest/views.py @@ -0,0 +1,16 @@ +from django.shortcuts import render +from django.views.generic import TemplateView + + +class Index(TemplateView): + template_name = 'index.html' + +""" +def handler404(request): + return render(request, '404.html', status=404) + + +def handler500(request): + return render(request, '500.html', status=500) + +""" \ No newline at end of file From 8ca9715ebdf6c9fac8f21be1f38cd2c3f819d695 Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Fri, 23 Feb 2024 04:19:12 +0100 Subject: [PATCH 2/6] hello world working and Linter --- tldtest/settings.py | 4 ++-- tldtest/views.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tldtest/settings.py b/tldtest/settings.py index 13f8445..b36936b 100644 --- a/tldtest/settings.py +++ b/tldtest/settings.py @@ -38,7 +38,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'admin_extra_buttons', - 'tldtester', + 'tldtester.apps.TldtesterConfig', ] MIDDLEWARE = [ @@ -56,7 +56,7 @@ ROOT_URLCONF = 'tldtest.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - "DIRS": [BASE_DIR / "templates"], + "DIRS": [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/tldtest/views.py b/tldtest/views.py index 0415afc..8959dc2 100644 --- a/tldtest/views.py +++ b/tldtest/views.py @@ -5,6 +5,7 @@ from django.views.generic import TemplateView class Index(TemplateView): template_name = 'index.html' + """ def handler404(request): return render(request, '404.html', status=404) @@ -13,4 +14,4 @@ def handler404(request): def handler500(request): return render(request, '500.html', status=500) -""" \ No newline at end of file +""" From 5251ec263995dc82bcc3c7932d588636142a4bfb Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Fri, 23 Feb 2024 18:31:25 +0100 Subject: [PATCH 3/6] More complex --- tldtest/settings.py | 3 ++- tldtest/templates/base.html | 12 ++++++++++++ tldtest/templates/{index.html => home.html} | 1 + tldtest/views.py | 4 +++- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tldtest/templates/base.html rename tldtest/templates/{index.html => home.html} (67%) diff --git a/tldtest/settings.py b/tldtest/settings.py index b36936b..8463465 100644 --- a/tldtest/settings.py +++ b/tldtest/settings.py @@ -39,6 +39,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'admin_extra_buttons', 'tldtester.apps.TldtesterConfig', + 'tldtest', ] MIDDLEWARE = [ @@ -56,7 +57,7 @@ ROOT_URLCONF = 'tldtest.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - "DIRS": [], + "DIRS": [BASE_DIR / "templates"], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/tldtest/templates/base.html b/tldtest/templates/base.html new file mode 100644 index 0000000..d61be45 --- /dev/null +++ b/tldtest/templates/base.html @@ -0,0 +1,12 @@ +{% load static %} + + + + + {% block title %}TLD Tester{% endblock %} + + +{% block content %} +{% endblock content %} + + \ No newline at end of file diff --git a/tldtest/templates/index.html b/tldtest/templates/home.html similarity index 67% rename from tldtest/templates/index.html rename to tldtest/templates/home.html index 819c632..1247810 100644 --- a/tldtest/templates/index.html +++ b/tldtest/templates/home.html @@ -1,3 +1,4 @@ +{% extends "base.html" %} {% block content %} Hello World {% endblock content %} diff --git a/tldtest/views.py b/tldtest/views.py index 8959dc2..6a72511 100644 --- a/tldtest/views.py +++ b/tldtest/views.py @@ -3,8 +3,10 @@ from django.views.generic import TemplateView class Index(TemplateView): - template_name = 'index.html' + template_name = 'home.html' +def home(request): + return render(request, 'home.html') """ def handler404(request): From 35bf01908924be2310ff9eb305d1bf4443ed6c29 Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Fri, 23 Feb 2024 18:37:07 +0100 Subject: [PATCH 4/6] proper linting --- tldtest/views.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tldtest/views.py b/tldtest/views.py index 6a72511..da5ec29 100644 --- a/tldtest/views.py +++ b/tldtest/views.py @@ -5,8 +5,6 @@ from django.views.generic import TemplateView class Index(TemplateView): template_name = 'home.html' -def home(request): - return render(request, 'home.html') """ def handler404(request): From c3b6e8cb5bca49e8d8fc04608ea7724da3c524f2 Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Fri, 23 Feb 2024 18:37:55 +0100 Subject: [PATCH 5/6] changing name of the tests --- .github/workflows/flake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml index d1bedb8..82ab4df 100644 --- a/.github/workflows/flake.yml +++ b/.github/workflows/flake.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Python application +name: Flake 8 on: push: From c002b2da8eb421150317d362f3b333adcfc49ba7 Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Fri, 23 Feb 2024 22:45:07 +0100 Subject: [PATCH 6/6] 404 and 500 --- tldtest/templates/404.html | 5 +++++ tldtest/templates/500.html | 5 +++++ tldtest/views.py | 3 --- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tldtest/templates/404.html create mode 100644 tldtest/templates/500.html diff --git a/tldtest/templates/404.html b/tldtest/templates/404.html new file mode 100644 index 0000000..e6be426 --- /dev/null +++ b/tldtest/templates/404.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} +{% block title %}Error 404{% endblock %} +{% block content %} + +{% endblock content %} diff --git a/tldtest/templates/500.html b/tldtest/templates/500.html new file mode 100644 index 0000000..8446050 --- /dev/null +++ b/tldtest/templates/500.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} +{% block title %}Error 404{% endblock %} +{% block content %} + +{% endblock content %} diff --git a/tldtest/views.py b/tldtest/views.py index da5ec29..a7fab18 100644 --- a/tldtest/views.py +++ b/tldtest/views.py @@ -6,12 +6,9 @@ class Index(TemplateView): template_name = 'home.html' -""" def handler404(request): return render(request, '404.html', status=404) def handler500(request): return render(request, '500.html', status=500) - -"""