我正在尝试在我的Ubuntu服务器上设置一个cronjob来运行django .py
文件 - 但是我首先运行该脚本时遇到了问题。
我正在使用命令python3 /opt/mydir/manage.py updatefm
产生错误:
File "/opt/mydir/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 324, in handle
raise NotImplementedError()
NotImplementedError
任何人都可以启发我的错误吗?这是我的脚本和结构:
/mydir
/mydir
__init__.py
/management
__init__.py
/commands
updatefm.py
updatefm.py
class Command(BaseCommand):
args = ''
help = 'Help Test'
def update_auto(self, *args, **options):
hi = 'test'
我的应用名称列在settings.py
中。
答案 0 :(得分:1)
检查__init__.py
文件夹中的commands
。然后你必须使用handle
方法
class Command(BaseCommand):
args = ''
help = 'Help Test'
def handle(self, *args, **options):
hi = 'test
答案 1 :(得分:1)
从BaseCommand
继承的类必须实现方法handle
。
在您的情况下,您应该更改
def update_auto(self, *args, **options):
到
def handle(self, *args, **options):