diff options
author | Mike Crute <mcrute@gmail.com> | 2010-12-30 01:08:53 -0500 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2010-12-30 01:08:53 -0500 |
commit | 1edce60c74427439160c85a9cbea1f2b61f6e45e (patch) | |
tree | bb50917e996db87dae2958d10bd8aaf1c7c5e2e6 | |
parent | ca58f2182b24717e1c3fb9f9da9397ff5e81fc2f (diff) | |
download | greenbox-1edce60c74427439160c85a9cbea1f2b61f6e45e.tar.bz2 greenbox-1edce60c74427439160c85a9cbea1f2b61f6e45e.tar.xz greenbox-1edce60c74427439160c85a9cbea1f2b61f6e45e.zip |
Adding new views for details, fixing regexes for urlconf
-rw-r--r-- | greenbox/recipe/urls.py | 1 | ||||
-rw-r--r-- | greenbox/recipe/views.py | 9 | ||||
-rw-r--r-- | greenbox/urls.py | 3 |
3 files changed, 10 insertions, 3 deletions
diff --git a/greenbox/recipe/urls.py b/greenbox/recipe/urls.py index d344e0a..4c937a0 100644 --- a/greenbox/recipe/urls.py +++ b/greenbox/recipe/urls.py | |||
@@ -2,5 +2,6 @@ from django.conf.urls.defaults import patterns, url | |||
2 | 2 | ||
3 | 3 | ||
4 | urlpatterns = patterns('recipe.views', | 4 | urlpatterns = patterns('recipe.views', |
5 | url(r'^(?P<slug>[^/]+)', 'recipe_details'), | ||
5 | url(r'^$', 'recipe_list'), | 6 | url(r'^$', 'recipe_list'), |
6 | ) | 7 | ) |
diff --git a/greenbox/recipe/views.py b/greenbox/recipe/views.py index d1872c5..3efdb9e 100644 --- a/greenbox/recipe/views.py +++ b/greenbox/recipe/views.py | |||
@@ -1,6 +1,11 @@ | |||
1 | from models import Recipe | 1 | from models import Recipe |
2 | from django.views.generic.list_detail import object_list | 2 | from django.views.generic import list_detail |
3 | 3 | ||
4 | 4 | ||
5 | def recipe_list(request): | 5 | def recipe_list(request): |
6 | return object_list(request, queryset=Recipe.objects.all()) | 6 | data = Recipe.objects.all() |
7 | return list_detail.object_list(request, queryset=data) | ||
8 | |||
9 | |||
10 | def recipe_details(request, slug): | ||
11 | return list_detail.object_detail(request, queryset=Recipe.objects.all(), slug=slug) | ||
diff --git a/greenbox/urls.py b/greenbox/urls.py index 7ee6f28..fb38894 100644 --- a/greenbox/urls.py +++ b/greenbox/urls.py | |||
@@ -2,6 +2,7 @@ from django.conf.urls.defaults import patterns, include, url | |||
2 | from django.contrib import admin; admin.autodiscover() | 2 | from django.contrib import admin; admin.autodiscover() |
3 | 3 | ||
4 | urlpatterns = patterns('', | 4 | urlpatterns = patterns('', |
5 | url(r'^$', include('recipe.urls')), | ||
6 | url(r'^admin/', include(admin.site.urls)), | 5 | url(r'^admin/', include(admin.site.urls)), |
6 | url(r'^recipe/', include('recipe.urls')), | ||
7 | url(r'^$', include('recipe.urls')), | ||
7 | ) | 8 | ) |