Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace direct_to_template by TemplateView.

  • Loading branch information...
commit 957cb2dc9e3e5e6d5ab0013e1555202bf460158e 1 parent 6f02d9c
Aymeric Augustin aaugustin authored
Showing with 8 additions and 18 deletions.
  1. +2 −5 contact/urls.py
  2. +2 −11 django_website/views.py
  3. +4 −2 django_www/urls.py
7 contact/urls.py
View
@@ -1,7 +1,7 @@
from __future__ import absolute_import
from django.conf.urls import patterns, url
-from django.views.generic.simple import direct_to_template
+from django.views.generic import TemplateView
from contact_form.views import contact_form
@@ -19,10 +19,7 @@
),
url(
regex=r'^sent/',
- view=direct_to_template,
- kwargs=dict(
- template='contact/sent.html',
- ),
+ view=TemplateView.as_view(template_name='contact/sent.html'),
name='contact_form_sent',
)
)
13 django_website/views.py
View
@@ -7,20 +7,16 @@
from django.contrib.sitemaps import views as sitemap_views
from django.shortcuts import render
from django.views.decorators.cache import cache_page
-from django.views.decorators.csrf import csrf_exempt, requires_csrf_token
+from django.views.decorators.csrf import requires_csrf_token
from django.views.generic import list_detail
-from django.views.generic.simple import direct_to_template
from .sitemaps import FlatPageSitemap, WeblogSitemap
-def homepage(request):
- return direct_to_template(request, 'homepage.html')
-
@cache_page(60*60*6)
def sitemap(request):
return sitemap_views.sitemap(request, sitemaps={
'weblog': WeblogSitemap,
- 'flatpages': FlatPageSitemap,
+ 'flatpages': FlatPageSitemap,
})
def comments(request):
@@ -30,11 +26,6 @@ def comments(request):
paginate_by = 30,
)
-@csrf_exempt
-def donate_thanks(request):
- return direct_to_template(request, 'donate_thanks.html')
-
-
@requires_csrf_token
def server_error(request, template_name='500.html'):
"""
6 django_www/urls.py
View
@@ -8,6 +8,8 @@
from django.contrib.flatpages.views import flatpage
from django.contrib.sitemaps import views as sitemap_views
from django.views.decorators.cache import cache_page
+from django.views.decorators.csrf import csrf_exempt
+from django.views.generic import TemplateView
from django.views.generic.simple import redirect_to
from accounts import views as account_views
@@ -31,7 +33,7 @@
urlpatterns = patterns('',
- url(r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'homepage.html'}, name="homepage"),
+ url(r'^$', TemplateView.as_view(template_name='homepage.html'), name="homepage"),
url(r'^accounts/', include('accounts.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^comments/$', 'django.views.generic.list_detail.object_list', comments_info_dict),
@@ -52,7 +54,7 @@
# PayPal insists on POSTing to the "thank you" page which means we can't
# just use a flatpage for it.
- url(r'^foundation/donate/thanks/$', 'django_website.views.donate_thanks'),
+ url(r'^foundation/donate/thanks/$', csrf_exempt(TemplateView.as_view(template_name='donate_thanks.html'))),
# django-push
url(r'^subscriber/', include('django_push.subscriber.urls')),
Please sign in to comment.
Something went wrong with that request. Please try again.