photoblog/views.py @ 7e2a0c0282b3

Really, Firefox?  I actually have to tell you to inherit the font-weight for a *div*?
author Steve Losh <steve@stevelosh.com>
date Thu, 19 Mar 2009 20:53:53 -0400
parents 91f05965e207
children (none)
from stevelosh.photoblog.models import Entry
from django.shortcuts import get_object_or_404, render_to_response

def entry(request, year=None, month=None, day=None, slug=None):
    if year == None and month == None and day == None and slug == None:
        entry = Entry.objects.all().order_by('-pub_date')[0]
    else:
        entry = get_object_or_404(Entry, slug=slug, pub_date__year=year, 
                                  pub_date__month=month, pub_date__day=day,)
    
    try:
        next = entry.get_next_by_pub_date()
    except Entry.DoesNotExist, e:
        next = None
    
    try:
        previous = entry.get_previous_by_pub_date()
    except Entry.DoesNotExist, e:
        previous = None
    
    return render_to_response('photoblog/entry.html', 
                { 'entry': entry, 'next': next, 'previous': previous })