Source

HH-Courses / views.py

from django.shortcuts import render_to_response
from models import Courses, Lessons

def course_index(request):
    try:
            c = Courses.active.all()
    except Courses.DoesNotExist:
            raise Http404
    return render_to_response('courses/course_index.html', locals(),context_instance=RequestContext(request))

def course_detail(request, slug):
    try:
            c = Courses.active.get(slug=slug)
    except Courses.DoesNotExist:
            raise Http404
    return render_to_response('courses/course_detail.html', locals(),context_instance=RequestContext(request))
        
def lesson_detail(request, slug):
    try:
            l = Lessons.active.get(slug=slug)
    except Lessons.DoesNotExist:
            raise Http404
    return render_to_response('courses/lesson_detail.html', locals(),context_instance=RequestContext(request))