1
我有一个ListView,我想在python中执行一个脚本来更新我们的数据库,每次我进入列表视图或定期。有没有办法在ListView中调用函数?
有没有办法做到这一点?
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()的问题。由于我使用的是Python 2.7,因此它要求提供一个参数。这可能是一些简单的东西,但我真的是Django的初学者。 –
我弄清楚了...我们必须调用这个类,用自己的 'response = super(AccesPointList,self).get(request,* args,** kwargs)' 响应是因为get方法返回对列表的回应。 –
啊,是的,超级需要Python 2中的参数。在python3中,你可以将它留空 – Brobin