From 9350814f570973fe47b975b400e77fbb58b89e4f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 May 2015 19:00:38 +0200 Subject: [PATCH] add detail view Signed-off-by: Nico Schottelius --- digital_glarus/templates/digital_glarus/detail.html | 11 +++++++++++ digital_glarus/urls.py | 4 ++-- digital_glarus/views.py | 12 +++++++++++- dynamicweb/urls.py | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 digital_glarus/templates/digital_glarus/detail.html diff --git a/digital_glarus/templates/digital_glarus/detail.html b/digital_glarus/templates/digital_glarus/detail.html new file mode 100644 index 00000000..77d404ce --- /dev/null +++ b/digital_glarus/templates/digital_glarus/detail.html @@ -0,0 +1,11 @@ +

{{ message }}

+ + + +

Back to Main diff --git a/digital_glarus/urls.py b/digital_glarus/urls.py index aa036dd0..1c6a5b83 100644 --- a/digital_glarus/urls.py +++ b/digital_glarus/urls.py @@ -4,6 +4,6 @@ from . import views urlpatterns = [ url(r'^$', views.index, name='index'), - url(r'/send_message', views.send_message, name='send_message'), -# url(r'^(?P[0-9]+)/$', views.detail, name='detail'), + url(r'send_message', views.send_message, name='send_message'), + url(r'^(?P[0-9]+)/$', views.detail, name='detail'), ] diff --git a/digital_glarus/views.py b/digital_glarus/views.py index 96986ed2..95da6bb8 100644 --- a/digital_glarus/views.py +++ b/digital_glarus/views.py @@ -1,11 +1,21 @@ from django.shortcuts import render -from django.shortcuts import render +from django.shortcuts import get_object_or_404, render + from .models import Message +def detail(request): + pass + +def detail(request, message_id): + p = get_object_or_404(Message, pk=message_id) + + context = { 'message': p, } + return render(request, 'digital_glarus/detail.html', context) + def send_message(request): pass diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index dfb7a04b..dc7bef66 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -7,5 +7,5 @@ urlpatterns = [ # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), - url(r'^digital.glarus/', include('digital_glarus.urls')), + url(r'^digital.glarus/', include('digital_glarus.urls', namespace="digital_glarus")), ]