From fef67254ee35abadabb05b38cd47e259c16ff8b9 Mon Sep 17 00:00:00 2001 From: gw3000 Date: Fri, 9 Jun 2023 09:20:27 +0200 Subject: [PATCH] next view and rendering it --- core/settings.py | 8 ++++++-- fbf/views.py | 7 +++---- templates/base.html | 4 ++-- templates/partials/_footer.html | 1 + templates/partials/_navbar.html | 1 + 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/settings.py b/core/settings.py index 2279a64..f82e547 100644 --- a/core/settings.py +++ b/core/settings.py @@ -10,6 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -58,7 +59,7 @@ ROOT_URLCONF = "core.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [os.path.join(BASE_DIR, 'templates')], "APP_DIRS": True, "OPTIONS": { "context_processors": [ @@ -123,7 +124,10 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = 'static/' +STATICFILES_DIRS = [ + BASE_DIR / "static" +] # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field diff --git a/fbf/views.py b/fbf/views.py index c1d2467..7cf04ad 100644 --- a/fbf/views.py +++ b/fbf/views.py @@ -7,10 +7,9 @@ def bird_create(request): def bird_all(request): - birds_all = FallenBird.objects.all() - for bird in birds_all: - print(bird) - return HttpResponse("Show all Birds") + birds = FallenBird.objects.all() + context = {'birds': birds} + return render(request, 'fbf/birds_all.html', context) def bird_recover_all(request): diff --git a/templates/base.html b/templates/base.html index 73d85e5..c4ed733 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,4 @@ -{load static} +{% load static %} @@ -14,7 +14,7 @@ {% comment %} possible dynamic header {% endcomment %} - {% block head_title %}lv·rb{% endblock %} + {% block head_title %}Fallen Birdy{% endblock %} {% comment %} custom header {% endcomment %} {% block header %} {% endblock header %} diff --git a/templates/partials/_footer.html b/templates/partials/_footer.html index e69de29..64a0a69 100644 --- a/templates/partials/_footer.html +++ b/templates/partials/_footer.html @@ -0,0 +1 @@ +footer diff --git a/templates/partials/_navbar.html b/templates/partials/_navbar.html index e69de29..16409c3 100644 --- a/templates/partials/_navbar.html +++ b/templates/partials/_navbar.html @@ -0,0 +1 @@ +navbar