from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from notes.models import Note def entry_detail(request, year, month, slug): context = { 'object': get_object_or_404(Note, slug__exact=slug), } return render_to_response( 'details/note.html', context, context_instance=RequestContext(request) ) def date_list(request, year, month=None): if month: qs = Note.objects.filter(date_created__year=year, date_created__month=month).order_by('-date_created') else: qs = Note.objects.filter(date_created__year=year).order_by('-date_created') context = { 'year': year, 'month': month, 'object_list': qs, } return render_to_response( "archives/notes_date.html", context, context_instance=RequestContext(request) ) def entry_list(request): context = { 'object_list': Note.objects.all().order_by('-date_created').select_related(), } return render_to_response("archives/notes.html", context, context_instance=RequestContext(request))