blob: eb6b0b15afdec3bcbee72846ecee32d5fd649924 (
plain)
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
|
# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.views.generic.list import ListView
from notice.models import Notice
class ListNoticeView(ListView):
"""
class-based view to show list of notice
"""
queryset = Notice.objects.all() # default order by '-pubtime'
template_name = 'notice/list_notice.html'
# allow queryset/model returns no object, otherwise 404error raised
allow_empty = True
def get_context_data(self, **kwargs):
"""
add 'user' context
"""
context = super(ListNoticeView, self).get_context_data(**kwargs)
user = self.request.user
context['user'] = user
return context
|