Source

mediatr / views.py

from datetime import datetime
from django.views.generic.list_detail import object_list, object_detail
from django.shortcuts import get_object_or_404, render_to_response, get_list_or_404
from django.conf import settings

from models import Item, Stream


def stream(request, slug):
    """
    Stream homepage
    """
    stream = get_object_or_404(Stream, slug=slug)
    params = dict()
    params['queryset'] = stream.items.filter(publish_date__lte=datetime.now()).order_by('-publish_date')
    params['paginate_by'] = settings.PAGINATE_BY
    params['extra_context'] = {'stream': stream}
    return object_list(request, **params)

def item(request, slug):
    """
    Stream item page
    """
    params = dict()
    params['queryset'] = Item.objects.filter(publish_date__lte=datetime.now())
    params['slug'] = slug
    return object_detail(request, **params)