From b1254fc736ab589895d31494db2fb9bc15c63651 Mon Sep 17 00:00:00 2001 From: Nadege Date: Tue, 5 Nov 2019 15:20:22 +0100 Subject: [PATCH] Template + Bootstrap --- news/settings.py | 1 + news/urls.py | 3 ++- posts/templates/posts/about.html | 12 +++++++++++ posts/templates/posts/index.html | 15 +++++++++++++ posts/urls.py | 6 ++++-- posts/views.py | 8 +++++++ templates/base.html | 36 ++++++++++++++++++++++++++++++++ 7 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 posts/templates/posts/about.html create mode 100644 posts/templates/posts/index.html create mode 100644 templates/base.html diff --git a/news/settings.py b/news/settings.py index cc6c0c3..9b20520 100644 --- a/news/settings.py +++ b/news/settings.py @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'posts' ] MIDDLEWARE = [ diff --git a/news/urls.py b/news/urls.py index 5b65b7b..8453b5d 100644 --- a/news/urls.py +++ b/news/urls.py @@ -14,7 +14,8 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import include, path +from django.urls import path,include +from posts import views urlpatterns = [ path('posts/', include('posts.urls')), diff --git a/posts/templates/posts/about.html b/posts/templates/posts/about.html new file mode 100644 index 0000000..3379a01 --- /dev/null +++ b/posts/templates/posts/about.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% block content %} + +

Seite Infos

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rhoncus + massa non tortor. Vestibulum diam diam, posuere in viverra in, + ullamcorper et libero. Donec eget libero quis risus congue imperdiet ac + id lectus. Nam euismod cursus arcu, et consequat libero ullamcorper sit + amet. +

+{% endblock %} \ No newline at end of file diff --git a/posts/templates/posts/index.html b/posts/templates/posts/index.html new file mode 100644 index 0000000..2430b2a --- /dev/null +++ b/posts/templates/posts/index.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% block content %} +
+
+

Meine Posts !

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rhoncus + massa non tortor. Vestibulum diam diam, posuere in viverra in, + ullamcorper et libero. Donec eget libero quis risus congue imperdiet ac + id lectus. Nam euismod cursus arcu, et consequat libero ullamcorper sit + amet. +

+
+
+{% endblock %} \ No newline at end of file diff --git a/posts/urls.py b/posts/urls.py index 3ef24d9..a0dd787 100644 --- a/posts/urls.py +++ b/posts/urls.py @@ -1,7 +1,9 @@ from django.urls import path - -from . import views +from posts import views urlpatterns = [ path('', views.index, name='index'), + path('welcome', views.welcome_seite), + path('home', views.welcome_seite), + path('about', views.about_seite) ] \ No newline at end of file diff --git a/posts/views.py b/posts/views.py index 1432f1b..0f04412 100644 --- a/posts/views.py +++ b/posts/views.py @@ -1,5 +1,13 @@ +from django.shortcuts import render from django.http import HttpResponse +from datetime import datetime # Create your views here. def index(request): return HttpResponse("Hello, world. You're at the posts index.") + +def welcome_seite(request): + return render(request, 'posts/index.html') + +def about_seite(request): + return render(request, 'posts/about.html') \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..008a23c --- /dev/null +++ b/templates/base.html @@ -0,0 +1,36 @@ + + + +{# #} + + + + {% block title %}First Django Application{% endblock %} + + + +
+ {% block content %}{% endblock %} +
+ + + \ No newline at end of file