]> git.p6c8.net - pcdenotes.git/blob - notes/views.py
Modified templates
[pcdenotes.git] / notes / views.py
1 from django.shortcuts import render, get_object_or_404
2 from django.core.paginator import Paginator
3
4 from pcdenotes.settings import NOTES_PER_PAGE
5 from .models import Note
6
7 # Create your views here.
8
9 def note_list(request):
10 notes = Note.objects.filter(status=1)
11 notes_count = Note.objects.filter(status=1).count()
12 paginator = Paginator(notes, NOTES_PER_PAGE)
13
14 page_number = 1
15
16 try:
17 page_number = int(request.GET.get('page'))
18 except:
19 pass
20
21 notes_page = paginator.get_page(page_number)
22
23 return render(request, 'note_list.html', {'notes_page': notes_page, 'notes_count': notes_count, 'pages': paginator, 'page_number': page_number})
24
25 def note_detail(request, note_slug):
26 note = get_object_or_404(Note, slug=note_slug, status=1)
27 return render(request, 'note_detail.html', {'note': note})

patrick-canterino.de