【发布时间】:2020-12-23 19:34:36
【问题描述】:
我想将变量的值发送到PostDetail 模板,
这是views.py文件的功能
class PostDetailView(DetailView):
model = Post
def get_object(self):
obj = super().get_object()
obj.view_count += 1
obj.save()
return obj
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
texts = self.object.content
Read_Time=get_read_time(texts)
print(Read_Time)
return context
这是终端的输出:-
[04/Sep/2020 19:29:04] "GET /post/this-blog-contains-an-image-with-it/ HTTP/1.1" 200 6089
0:02:00
[04/Sep/2020 19:29:24] "GET /post/this-blog-contains-an-image-with-it/ HTTP/1.1" 200 6089
我想将0:02:00 发送到我的模板,我该如何实现?
【问题讨论】: