1
我有一個dayarchiveview在我的Django views.py文件我想繼承的dayarchiveview這樣我就可以使數據不同
class day_archive(DayArchiveView):
model=Timer
paginate_by=12
allow_future =True
allow_empty=True
month_format = '%m'
day_format='%d'
date_field='start_hour'
template_name='timer/timer_archive_date'
def get_queryset(self):
return Timer.objects.filter(author=self.request.user)
,但我想使返回的數據爲表使用djangotables2的東西像這樣:
import django_tables2 as tables
class Job_table(tables.Table):
class Meta:
model = Timer
attrs = {"class": "paleblue"}
fields= ('start_hour','end_hour','category','subcategory','duration')
def render_duration(self,value):
from timehuman import sectohour
hh= sectohour(value)
return hh
我該如何渲染我的數據而不是呈現列表? (由Django的上下文object_list)我如何訪問將發送到object_list上下文並修改它的數據?