From 0cca1ed501fa874304eb6d7b68615750ed270261 Mon Sep 17 00:00:00 2001 From: HugoNeveux Date: Tue, 21 Apr 2020 12:18:56 +0200 Subject: [PATCH] Moved base templates to /templates and index.html to /front/templates --- PDMI/PDMI/settings.py | 6 +++++- PDMI/PDMI/urls.py | 3 ++- PDMI/{store => front}/templates/index.html | 0 PDMI/front/urls.py | 21 +++++++++++++++++++++ PDMI/store/urls.py | 1 - PDMI/store/views.py | 2 -- PDMI/{store => }/templates/base/base.html | 0 PDMI/{store => }/templates/base/navbar.html | 0 8 files changed, 28 insertions(+), 5 deletions(-) rename PDMI/{store => front}/templates/index.html (100%) create mode 100644 PDMI/front/urls.py rename PDMI/{store => }/templates/base/base.html (100%) rename PDMI/{store => }/templates/base/navbar.html (100%) diff --git a/PDMI/PDMI/settings.py b/PDMI/PDMI/settings.py index ce4c023..0590648 100644 --- a/PDMI/PDMI/settings.py +++ b/PDMI/PDMI/settings.py @@ -38,6 +38,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'store', + 'doc', + 'front', ] MIDDLEWARE = [ @@ -55,7 +57,9 @@ ROOT_URLCONF = 'PDMI.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/PDMI/PDMI/urls.py b/PDMI/PDMI/urls.py index 106169c..73ec594 100644 --- a/PDMI/PDMI/urls.py +++ b/PDMI/PDMI/urls.py @@ -15,9 +15,10 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include -import store +import store, front urlpatterns = [ path('admin/', admin.site.urls), + path('', include('front.urls')), path('store/', include('store.urls')) ] diff --git a/PDMI/store/templates/index.html b/PDMI/front/templates/index.html similarity index 100% rename from PDMI/store/templates/index.html rename to PDMI/front/templates/index.html diff --git a/PDMI/front/urls.py b/PDMI/front/urls.py new file mode 100644 index 0000000..bef1b9d --- /dev/null +++ b/PDMI/front/urls.py @@ -0,0 +1,21 @@ +"""PDMI URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.urls import path, include +from django.views.generic import TemplateView + +urlpatterns = [ + path('', TemplateView.as_view(template_name="index.html"), name='index') +] diff --git a/PDMI/store/urls.py b/PDMI/store/urls.py index 83352e9..4674faf 100644 --- a/PDMI/store/urls.py +++ b/PDMI/store/urls.py @@ -18,5 +18,4 @@ import store.views import store urlpatterns = [ - path('index/', store.views.index), ] diff --git a/PDMI/store/views.py b/PDMI/store/views.py index b8297fe..91ea44a 100644 --- a/PDMI/store/views.py +++ b/PDMI/store/views.py @@ -1,5 +1,3 @@ from django.shortcuts import render # Create your views here. -def index(request): - return render(request, 'index.html') diff --git a/PDMI/store/templates/base/base.html b/PDMI/templates/base/base.html similarity index 100% rename from PDMI/store/templates/base/base.html rename to PDMI/templates/base/base.html diff --git a/PDMI/store/templates/base/navbar.html b/PDMI/templates/base/navbar.html similarity index 100% rename from PDMI/store/templates/base/navbar.html rename to PDMI/templates/base/navbar.html