Here are the slides to the presentation on class-based views for Django that I gave at the Whatcom Python users group today. Be sure to check out the code that goes along with it, as well as the links for further reading at the end of the slides (especially Simon Willison's "Django Heresies").

Here is an example of using class based views straight out of our repo at WWU University Residences. This should give you an idea what views look like when you use classes.


class Index(View):
    """Index view for RD Search."""
    template_name = "rdsearch/index.html"
    decorators = [decorate_method_with(login_required)]

    def get_context(self, request, *args, **kwargs):
        applicants = applicants_for_user(request.user.username)
        return {
            "applicant_stages": self._applicants_by_stage(applicants)

    def _applicants_by_stage(self, applicants):
        stages = list(set([app["stage"] for app in applicants]))
        return [(pretty_stage(stage), applicants.filter(stage=stage))
                for stage in stages]


# Using "instantiator" to create new instances of the view class for each
# request. "instantiator" is located with the "View" class.

urlpatterns = patterns('',
    # ...
    url(r'^$', instantiator(Index), name="rdsearch_index"),
    # ...