[damned-lies] Remove/replace old-style generic views



commit 6ce2b20832d0ed7cb178e28376e66612bf003515
Author: Claude Paroz <claude 2xlibre net>
Date:   Tue May 17 08:46:11 2011 +0200

    Remove/replace old-style generic views

 teams/urls.py |   25 +++++--------------------
 urls.py       |    4 ++--
 2 files changed, 7 insertions(+), 22 deletions(-)
---
diff --git a/teams/urls.py b/teams/urls.py
index 72eabe6..3c8a287 100644
--- a/teams/urls.py
+++ b/teams/urls.py
@@ -1,31 +1,16 @@
-from django.conf.urls.defaults import *
-from teams.models import Team
+from django.conf.urls.defaults import patterns, url
 
-info_dict = {
-    'queryset': Team.objects.all(),
-    'template_object_name': 'team',
-    'slug_field': 'name',
-    'extra_context': {
-        'pageSection': "teams"
-    }
-}
-
-urlpatterns = patterns('',
+urlpatterns = patterns('teams.views',
     url(
         regex = r'^(?P<format>(xml))?/?$',
-        view = 'teams.views.teams',
+        view = 'teams',
         name = 'teams'),
     url(
         regex = r'^(?P<team_slug>[\w\- ]+)/$',
-        view = 'teams.views.team',
+        view = 'team',
         name = 'team_slug'),
     url(
         regex = r'^(?P<team_slug>[\w\- ]+)/edit/',
-        view = 'teams.views.team_edit',
+        view = 'team_edit',
         name = 'team_edit'),
-    url(
-        regex = r'^(?P<object_id>\d+)',
-        view = 'django.views.generic.list_detail.object_detail',
-        kwargs = dict(info_dict),
-        name = 'team')
 )
diff --git a/urls.py b/urls.py
index 978f25b..322722f 100644
--- a/urls.py
+++ b/urls.py
@@ -1,6 +1,7 @@
 from django.conf.urls.defaults import *
 from django.conf import settings
 from django.contrib import admin
+from django.views.generic import TemplateView
 
 admin.autodiscover()
 
@@ -19,8 +20,7 @@ urlpatterns = patterns('',
         name = 'register'),
     url(
         regex = r'^register/success$',
-        view = 'django.views.generic.simple.direct_to_template',
-        kwargs = {'template': 'registration/register_success.html'},
+        view = TemplateView.as_view(template_name="registration/register_success.html"),
         name = 'register_success'),
     url(
         regex = r'^register/activate/(?P<key>\w+)$',



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]