From d5c04c7deecf30425976812e874b12f165def3de Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 13 Apr 2020 10:39:38 +0100 Subject: [PATCH] Add homepage template view --- templates/base.html | 23 +++++++++++++++++++++++ templates/index.html | 7 +++++++ website/common/__init__.py | 0 website/common/urls.py | 5 +++++ website/common/views.py | 5 +++++ website/settings.py | 3 ++- website/urls.py | 4 +++- 7 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 templates/base.html create mode 100644 templates/index.html create mode 100644 website/common/__init__.py create mode 100644 website/common/urls.py create mode 100644 website/common/views.py diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..7cd55d5 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,23 @@ +{% load static %} + + + + + + + + + + + + {% block title %}{% endblock %} :: TheOrangeOne + + + + + + {% block content %}{% endblock %} + + + + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..da8bff3 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block title %}Homepage{% endblock %} + +{% block content %} +Homepage content +{% endblock%} diff --git a/website/common/__init__.py b/website/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/common/urls.py b/website/common/urls.py new file mode 100644 index 0000000..eb1dae5 --- /dev/null +++ b/website/common/urls.py @@ -0,0 +1,5 @@ +from django.urls import path + +from . import views + +urlpatterns = [path("", views.HomepageView.as_view())] diff --git a/website/common/views.py b/website/common/views.py new file mode 100644 index 0000000..9d7dbe6 --- /dev/null +++ b/website/common/views.py @@ -0,0 +1,5 @@ +from django.views.generic import TemplateView + + +class HomepageView(TemplateView): + template_name = "index.html" diff --git a/website/settings.py b/website/settings.py index 5cae96f..22d9bf5 100644 --- a/website/settings.py +++ b/website/settings.py @@ -38,6 +38,7 @@ INSTALLED_APPS = [ "whitenoise.runserver_nostatic", "django.contrib.staticfiles", "debug_toolbar", + "website.common", ] MIDDLEWARE = [ @@ -54,7 +55,7 @@ ROOT_URLCONF = "website.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [os.path.join(BASE_DIR, "templates")], "APP_DIRS": True, "OPTIONS": { "context_processors": [ diff --git a/website/urls.py b/website/urls.py index 8f32c2e..124f4e9 100644 --- a/website/urls.py +++ b/website/urls.py @@ -2,7 +2,9 @@ import debug_toolbar from django.conf import settings from django.urls import include, path -urlpatterns = [] +from website.common.urls import urlpatterns as common_urlpatterns + +urlpatterns = [path("", include(common_urlpatterns))] if settings.DEBUG: urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))