Rewrite to Django from scratch. Now it's much more user-friendly.
[cookbook.git] / cookbook / views.py
diff --git a/cookbook/views.py b/cookbook/views.py
new file mode 100644 (file)
index 0000000..dbc1bd2
--- /dev/null
@@ -0,0 +1,14 @@
+from django.http import HttpResponse
+from django.shortcuts import render_to_response, get_object_or_404
+from django.template import RequestContext
+
+from taggit.models import Tag
+from .models import Recipe
+
+
+def tag(request, pk):
+    tag = get_object_or_404(Tag, pk=pk)
+    recipes = Recipe.objects.filter(tags__name__in=[tag.slug])
+    return render_to_response(
+        'cookbook/recipes.html', {'recipes': recipes, 'title': tag.name},
+        RequestContext(request))