Commits

Andy Mikhailenko committed e8436c9

Improved documentation for decorators.

  • Participants
  • Parent commits 6e9e5c9

Comments (0)

Files changed (1)

File view_shortcuts/decorators.py

 
         >>> @render_to('foo.html')
         ... def view_foo(request):
-        ...     return {'foo':'bar'}
+        ...     return {'foo': 'bar'}
         ...
 
     Template name can be omitted. The following code will render the output
         >>> @render_to()
         ... def foo_detail(request, pk):
         ...     obj = Foo.objects.get(pk=pk)
-        ...     return {'object':obj}
+        ...     return {'object': obj}
+
+    Class views are supported too::
+
+        >>> @render_to()
+        ... class ViewFoo(object):
+        ...     def __init__(self, foo):
+        ...         self.foo = foo
+        ...     def __call__(self, request, *args, **kwargs):
+        ...         qs = Foo.objects.filter(foo=self.foo)
+        ...         return {'object_list': qs}
 
     Source: <http://piranha.org.ua/blog/2008/03/22/render-to-improved/>