Restructure cookbook directories and use Grappelli for the admin interface.
[cookbook.git] / cookbook / urls.py
1 from django.conf import settings
2 from django.conf.urls.defaults import patterns, include, url
3 from django.views.generic import DetailView, ListView
4 import taggit.models
5
6 from . import models
7 from . import views
8
9 # Uncomment the next two lines to enable the admin:
10 from django.contrib import admin
11 admin.autodiscover()
12
13 urlpatterns = patterns('',
14     url(r'^$', views.static_context_list_view_factory(
15             extra_context={'title': 'Recipes'},
16             ).as_view(
17             queryset=models.Recipe.objects.all().order_by('name'),
18             context_object_name='recipes',
19             template_name='cookbook/recipes.html'),
20         name='recipes'),
21      url(r'^recipe/(?P<pk>\d+)/$', DetailView.as_view(
22             model=models.Recipe, template_name='cookbook/recipe.html'),
23         name='recipe'),
24      url(r'^tags/$', views.static_context_list_view_factory(
25             extra_context={'title': 'Tags'},
26             ).as_view(
27             queryset=taggit.models.Tag.objects.all(),
28             context_object_name='tags',
29             template_name='cookbook/tags.html'),
30         name='tags'),
31      url(r'^tag/(?P<pk>\d+)/$', 'cookbook.views.tag', name='tag'),
32
33     # Uncomment the admin/doc line below to enable admin documentation:
34     # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
35
36     # Uncomment the next line to enable the admin:
37     url(r'^admin/', include(admin.site.urls), name='admin'),
38     url(r'^grappelli/', include('grappelli.urls'), name='admin'),
39
40     url(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to',
41         kwargs={'url': settings.STATIC_URL + 'cookbook.ico'}),
42 )