diff --git a/pages/models.py b/pages/models.py index 71a8362..2e5ed8e 100644 --- a/pages/models.py +++ b/pages/models.py @@ -1,3 +1,11 @@ from django.db import models # Create your models here. + + +def add_note(note, notes=[]): + """ + Adds a note to the notes list and returns the list. + """ + notes.append(note) + return notes diff --git a/pages/views.py b/pages/views.py index 886a2ba..1b25563 100644 --- a/pages/views.py +++ b/pages/views.py @@ -1,9 +1,16 @@ from django.views.generic import TemplateView +from .models import add_note class HomePageView(TemplateView): template_name = "pages/home.html" + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + notes = add_note("Visited home page") + context["notes"] = notes + return context + class AboutPageView(TemplateView): template_name = "pages/about.html" diff --git a/templates/pages/home.html b/templates/pages/home.html index c3b6c45..e8d1b32 100644 --- a/templates/pages/home.html +++ b/templates/pages/home.html @@ -1,11 +1,21 @@ -{% extends '_base.html' %} -{% load static %} - -{% block title %}Home page{% endblock title %} - -{% block content %} +{% extends '_base.html' %} {% load static %} {% block title %}Home page{% +endblock title %} {% block content %}
- Lithium logo + Lithium logo

A Django starter project with batteries.

-{% endblock content %} + +{% if notes %} +
+ Notes: + +
+{% endif %} {% endblock content %}