diff --git a/MEIM_Lsg/urls.py b/MEIM_Lsg/urls.py index de7c316..335a9cc 100644 --- a/MEIM_Lsg/urls.py +++ b/MEIM_Lsg/urls.py @@ -15,9 +15,10 @@ Including another URLconf """ from django.contrib import admin from django.urls import include, path -import posts +from . import views urlpatterns = [ path('admin/', admin.site.urls), + path('', views.index, name='posts'), path('posts/', include('posts.urls'), name='posts') ] diff --git a/MEIM_Lsg/views.py b/MEIM_Lsg/views.py new file mode 100644 index 0000000..d2f983b --- /dev/null +++ b/MEIM_Lsg/views.py @@ -0,0 +1,5 @@ +from django.shortcuts import render +# Create your views here. + +def index(request): + return render(request, 'index.html') \ No newline at end of file diff --git a/posts/urls.py b/posts/urls.py index 0b00eb9..13b18f9 100644 --- a/posts/urls.py +++ b/posts/urls.py @@ -4,5 +4,5 @@ from django.urls import path, re_path urlpatterns = [ # use re_path for regex (.*) - this regex accepts anything - see https://docs.python.org/3/library/re.html for more path('', views.home, name=''), - re_path('(?P.*)/$', views.home, name='textwiedergabe') + re_path('(?P.*)/$', views.home, name='textausgabe') ] \ No newline at end of file diff --git a/posts/views.py b/posts/views.py index 0d02d4e..ae418fe 100644 --- a/posts/views.py +++ b/posts/views.py @@ -1,6 +1,9 @@ -from django.http import HttpResponse +from django.shortcuts import render # Create your views here. -# if no value is given use the default '' -def home(request, value=''): - return HttpResponse(value) \ No newline at end of file +def home(request, value=""): + context = { + "title": "Beboop", + "message": value + } + return render(request, 'index.html', context) \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..72189cd --- /dev/null +++ b/templates/base.html @@ -0,0 +1,41 @@ + + + + + + + + + + + {% block title %} {% endblock %} + + + + {% block content %} {% endblock %} + + + + + + + + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..536b3d2 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block title %} {{ title }} {% endblock title %} + +{% block content %} +
+

My first post!

+

{{message}}

+
+{% endblock content %} \ No newline at end of file