]>
git.p6c8.net - pcdenotes.git/blob - notes/views.py
793f9ed49649edfa89ddb36ee1d8a72d143e73a2
1 from django
.shortcuts
import render
, get_object_or_404
2 from django
.core
.paginator
import Paginator
4 from pcdenotes
.settings
import NOTES_PER_PAGE
5 from .models
import Note
7 # Create your views here.
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
)
17 page_number
= int(request
.GET
.get('page'))
21 page_count
= paginator
.num_pages
23 notes_page
= paginator
.get_page(page_number
)
25 return render(request
, 'note_list.html', {'notes_page': notes_page
, 'notes_count': notes_count
, 'pages': paginator
, 'page_number': page_number
, 'page_count': page_count
})
27 def note_detail(request
, note_slug
):
28 note
= get_object_or_404(Note
, slug
=note_slug
, status
=1)
29 return render(request
, 'note_detail.html', {'note': note
})
patrick-canterino.de