1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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))
|