我有一个ListView,我想在python中执行一个脚本,以便每次我进入列表视图时或定期输入更新数据库。
有没有办法做到这一点 ?
class AccessPointList(generic.ListView): #receives the whole set of AccessPoint and send to HTML
model = AccessPoint
#call a function in python -> c.update()
#or create a def to update our database
当然,在要运行它时只需重写其中一种方法,然后调用super继续正常执行ListView
class AccessPointList(generic.ListView):
model = AccessPoint
def get(self, request, *args, **kwargs):
# call your function
return super().get(request, *args, **kwargs)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句