urlpatterns = [
url(r'^$', views.index, name='index'),
- url(r'^(?P<animal_id>[0-9]+)/$', views.detail),
+ url(r'^(?P<animal_name>\w+)/$', views.detail),
]
return HttpResponse("Hello, world. You're at the animals index.")
-def detail(request, animal_id):
+def detail(request, animal_name):
# return HttpResponse("Hello, world. You're at the animal {}.".format(animal_id))
- animal = get_object_or_404(Animal, pk=animal_id)
+ animal = get_object_or_404(Animal, name_german=animal_name)
+
return render(request, 'animals/detail.html', {'animal': animal})