From 2fa1060c2b4ff808834251a9e36be456b6af896f Mon Sep 17 00:00:00 2001 From: Kriti Godey Date: Tue, 2 Mar 2010 15:36:04 -0500 Subject: [PATCH] Added a single sandwich view + url pattern. --- templates/onesandwich.html | 17 +++++++++++++++++ urls.py | 1 + views.py | 11 ++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 templates/onesandwich.html diff --git a/templates/onesandwich.html b/templates/onesandwich.html new file mode 100644 index 0000000..0feaa5b --- /dev/null +++ b/templates/onesandwich.html @@ -0,0 +1,17 @@ + + + Every Ma'ayanwich Ever! + +

{{ s.adjective }}

+

Made on {{ s.date_made }} and added by {{ s.user.username }}.

+ +
Ingredients
+ +
Notes
+

{{ s.notes }}

+ + \ No newline at end of file diff --git a/urls.py b/urls.py index 8d04d4b..a2025b8 100644 --- a/urls.py +++ b/urls.py @@ -7,4 +7,5 @@ urlpatterns = patterns('', (r'^addingredient/$', views.add_ingredient), (r'^allsandwiches/$', views.all_sandwich), (r'^newsandwiches/$', views.newsandwiches), + (r'^sandwich/(?P[-\w]+)/$', views.specific_sandwich), ) diff --git a/views.py b/views.py index 3b12aec..dff7b66 100644 --- a/views.py +++ b/views.py @@ -41,6 +41,7 @@ def all_sandwich(request): except Sandwich.DoesNotExist: raise Http404 return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,}) + def newsandwiches(request): try: @@ -50,4 +51,12 @@ def newsandwiches(request): sandwiches = Sandwich.objects.order_by('date_made') except Sandwich.DoesNotExist: raise Http404 - return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,}) \ No newline at end of file + return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,}) + + +def specific_sandwich(request, slug): + try: + sandwiches = Sandwich.objects.get(slug=slug) + except Sandwich.DoesNotExist: + raise Http404 + return render_to_response('onesandwich.html', {'s': sandwiches,}) \ No newline at end of file -- 2.20.1