From 80a75a445edccfdbc5b272257ce343f217ab8ad5 Mon Sep 17 00:00:00 2001 From: Pierre Geeraert Date: Fri, 30 May 2025 11:51:23 +0100 Subject: [PATCH] working on views --- django_code/dashboard/templates/about.html | 32 ++++++++++++++++++++++ django_code/dashboard/templates/home.html | 18 ++++++++++++ django_code/dashboard/views.py | 9 ++++++ django_code/django_code/settings.py | 6 ++-- django_code/django_code/urls.py | 7 +++-- 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 django_code/dashboard/templates/about.html create mode 100644 django_code/dashboard/templates/home.html create mode 100644 django_code/dashboard/views.py diff --git a/django_code/dashboard/templates/about.html b/django_code/dashboard/templates/about.html new file mode 100644 index 0000000..3779b7e --- /dev/null +++ b/django_code/dashboard/templates/about.html @@ -0,0 +1,32 @@ + + + + {% block title %}{% endblock %} + {% load bootstrap5 %} + {% bootstrap_css %} + {% bootstrap_javascript %} + + + +

Welcome to my website!

+ +
+
+ {% if thislist %} + + {% else %} +

No polls are available.

+ {% endif %} +
+
+ + + {% block content %} + {% endblock %} + + + diff --git a/django_code/dashboard/templates/home.html b/django_code/dashboard/templates/home.html new file mode 100644 index 0000000..21544fc --- /dev/null +++ b/django_code/dashboard/templates/home.html @@ -0,0 +1,18 @@ + + + + My Website + + +

Welcome to my website!

+ {% if thislist %} + +{% else %} +

No polls are available.

+{% endif %} + + \ No newline at end of file diff --git a/django_code/dashboard/views.py b/django_code/dashboard/views.py new file mode 100644 index 0000000..6175269 --- /dev/null +++ b/django_code/dashboard/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render + +def home(request): + thislist = ["apple", "banana", "cherry"] + return render(request, 'home.html',{'thislist': thislist}) + +def about(request): + thislist = ["apple", "banana", "cherry"] + return render(request, 'about.html',{'thislist': thislist}) diff --git a/django_code/django_code/settings.py b/django_code/django_code/settings.py index 45d5d01..63299e1 100644 --- a/django_code/django_code/settings.py +++ b/django_code/django_code/settings.py @@ -25,7 +25,7 @@ SECRET_KEY = 'django-insecure-71%)_#e#o9-dl2o^6mfud-*rw+4+8vy-nd*bzeier&(34ap-p9 # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu'] +ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu','localhost'] # Application definition @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'bootstrap5', ] MIDDLEWARE = [ @@ -54,7 +55,8 @@ ROOT_URLCONF = 'django_code.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': ["/code/django_code/templates"], + #'DIRS': ["/code/django_code/templates","/code/django_code/dashboard/templates/"], + 'DIRS': [BASE_DIR / "templates","django_code/dashboard/templates/"], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/django_code/django_code/urls.py b/django_code/django_code/urls.py index 9e9fe09..9fe83b5 100644 --- a/django_code/django_code/urls.py +++ b/django_code/django_code/urls.py @@ -20,7 +20,8 @@ from django.urls import path from random_simpsons import apps as random_simpsons from paperless_django import apps as paperless_django from onenote import apps as onenote -from dashboard import apps as dashboard +from dashboard import apps as dashboardapp +from dashboard import views as dashboardview from kubernetes_connection import apps as kubernetes_connection urlpatterns = [ @@ -39,7 +40,9 @@ urlpatterns = [ path('onenote/hello/', onenote.hello), ################### onenote ################### - path('dashboard/hello/', dashboard.hello), + path('dashboard/hello/', dashboardapp.hello), + path('dashboard/view/about', dashboardview.about), + path('dashboard/view/home', dashboardview.home), ################## kubernetes_connection#####