Commits

Mathieu Agopian committed 0ad7286

include a CBV in testapp for convenience, pep8 clean

  • Participants
  • Parent commits 35c1a1e

Comments (0)

Files changed (4)

File sqlite_settings.py

     'django.contrib.admindocs',
     'testapp',
 )
-

File testapp/tests.py

 
 
 class SimpleTest(TestCase):
+
     def test_basic_addition(self):
         """
         Tests that 1 + 1 always equals 2.

File testapp/urls.py

 
 from django.conf.urls.defaults import patterns, url
 from django.views.generic.simple import direct_to_template
+from testapp.views import home_view
 
 
 urlpatterns = patterns('',
-    url(r'^$',
-        direct_to_template,
-        {'template': 'testapp/index.html'},
-        name='home'),
+    url(r'^$', home_view, name='home'),
 )

File testapp/views.py

-# Create your views here.
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from django.views.generic.base import TemplateView
+
+
+class HomeView(TemplateView):
+    template_name = 'testapp/index.html'
+
+    def get_context_data(self, **kwargs):
+        context = super(HomeView, self).get_context_data(**kwargs)
+
+        # add your specific context here if needed
+        context['foo'] = 'bar'
+
+        return context
+home_view = HomeView.as_view()