add detail view

Signed-off-by: Nico Schottelius <nico@freiheit.schottelius.org>
This commit is contained in:
Nico Schottelius 2015-05-02 19:00:38 +02:00
parent 7f7e5be1c6
commit 9350814f57
4 changed files with 25 additions and 4 deletions

View file

@ -0,0 +1,11 @@
<h1>{{ message }}</h1>
<ul>
<li>{{ message.name }}
<li>{{ message.email }}
<li>{{ message.phone_number }}
<li>{{ message.message }}
<li>{{ message.received_date }}
</ul>
<p><a href="{% url 'digital_glarus:index' %}">Back to Main</a>

View file

@ -4,6 +4,6 @@ from . import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.index, name='index'), url(r'^$', views.index, name='index'),
url(r'/send_message', views.send_message, name='send_message'), url(r'send_message', views.send_message, name='send_message'),
# url(r'^(?P<message_id>[0-9]+)/$', views.detail, name='detail'), url(r'^(?P<message_id>[0-9]+)/$', views.detail, name='detail'),
] ]

View file

@ -1,11 +1,21 @@
from django.shortcuts import render from django.shortcuts import render
from django.shortcuts import render from django.shortcuts import get_object_or_404, render
from .models import Message 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): def send_message(request):
pass pass

View file

@ -7,5 +7,5 @@ urlpatterns = [
# url(r'^blog/', include('blog.urls')), # url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.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")),
] ]