Adjusted template for animal properties like {'size_cm': 70, 'names': ['Alfons',...
[toast/alpenzoo.git] / animals / views.py
1 from django.shortcuts import get_object_or_404, render
2 from django.http import HttpResponse
3 from .models import Animal
4
5
6 def index(request):
7     animals = Animal.objects.all()
8     return render(request, 'animals/list.html', {'animals': animals})
9
10
11 def detail(request, animal_name):
12     # return HttpResponse("Hello, world. You're at the animal {}.".format(animal_id))
13     animal = get_object_or_404(Animal, name_german=animal_name)
14
15     return render(request, 'animals/detail.html', {'animal': animal})