【发布时间】:2017-03-26 10:02:05
【问题描述】:
当我跑步时 (nohup python -u rerank.py&)
我有以下:
Traceback (most recent call last):
File "rerank.py", line 24, in <module>
rank_all()
File "rerank.py", line 11, in rank_all
Link.set_rank()
TypeError: unbound method set_rank() must be called with Link instance as first argument (got nothing instead)
我的文件 rerank.py 看起来像这样,但我没有找到任何 gem
#!/usr/bin/env python
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "news_factory.settings")
django.setup()
from news.models import Link
def rank_all():
for link in Link.with_votes.all():
Link.set_rank()
import time
def show_all():
print "\n".join("%10s %0.2f" % (l.title, l.rank_score,) for l in
Link.with_votes.all())
print "----\n\n\n"
if __name__ == "__main__":
while 1:
print "---"
rank_all()
show_all()
time.sleep(5)
非常感谢您的帮助
【问题讨论】: