Created animal overview page.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 28 Jul 2015 19:30:57 +0000 (21:30 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 28 Jul 2015 19:30:57 +0000 (21:30 +0200)
animals/templates/animals/list.html [new file with mode: 0644]
animals/urls.py
animals/views.py

diff --git a/animals/templates/animals/list.html b/animals/templates/animals/list.html
new file mode 100644 (file)
index 0000000..c13329f
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:py="http://genshi.edgewall.org/"
+       xmlns:xi="http://www.w3.org/2001/XInclude"
+       lang="de">
+  <head>
+    <meta charset="utf-8"/>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1"/>
+    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
+    <meta name="description" content="" />
+    <meta name="author" content="" />
+    <link rel="icon" href="${static('favicon.ico')}" />
+
+    <title>Tiere</title>
+
+    <!-- Bootstrap core CSS -->
+    <link href="${static('bootstrap/css/bootstrap.min.css')}" rel="stylesheet"/>
+
+    <!-- Custom styles for this template -->
+    <link href="${static('animals/animals.css')}" rel="stylesheet"/>
+
+  </head>
+
+  <body>
+
+    <div class="container">
+      <div class="header clearfix">
+        <nav>
+          <ul class="nav nav-pills pull-right">
+            <li role="presentation" class="active"><a href="#">Alpenzoo</a></li>
+            <li role="presentation"><a href="#">Tiere</a></li>
+            <li role="presentation"><a href="#">Spiele</a></li>
+          </ul>
+        </nav>
+        <h3 class="text-muted">Alpenzoo</h3>
+      </div>
+
+      <div class="jumbotron">
+        <h1>Unsere Tiere</h1>
+        <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
+        <p>
+                       <a class="btn btn-lg btn-success" href="#" role="button">Rundgang beginnen</a>
+                       <a class="btn btn-lg btn-success" href="#" role="button">Quiz</a>
+               </p>
+      </div>
+
+               <ul>
+          <li py:for="animal in animals"><a href="${url('animal_detail', animal.name_german)}">${animal.name_german}</a></li>
+               </ul>
+
+      <footer class="footer">
+        <p>&copy; Sabine, Georg, Gregor, Philipp 2015</p>
+      </footer>
+
+    </div> <!-- /container -->
+
+  </body>
+</html>
index 9fe80a968e5dcb1f35d14914057ef7d1332b8fad..b58f7688c9545279d29eafb26088b568f497aec5 100644 (file)
@@ -3,6 +3,6 @@ from django.conf.urls import url
 from . import views
 
 urlpatterns = [
-    url(r'^$', views.index, name='index'),
-    url(r'^(?P<animal_name>\w+)/$', views.detail),
+    url(r'^$', views.index, name='animal_list'),
+    url(r'^(?P<animal_name>\w+)/$', views.detail, name='animal_detail'),
 ]
index 48da423e0d44e397e3f49bcfcda1151a5d1022bc..4aa4417cbebd84dd624bfa5ce842b998cb886798 100644 (file)
@@ -2,9 +2,10 @@ from django.shortcuts import get_object_or_404, render
 from django.http import HttpResponse
 from .models import Animal
 
-# Create your views here.
+
 def index(request):
-    return HttpResponse("Hello, world. You're at the animals index.")
+    animals = Animal.objects.all()
+    return render(request, 'animals/list.html', {'animals': animals})
 
 
 def detail(request, animal_name):