사용자 정의 django-admin 명령을 작성했습니다. 내가 사용하는 단말기가이 명령을 실행할 때사용자 정의 django-admin 명령 : 사용 모델 및 crontab 문제
import os
from home.models import BuildTask
class Command(BaseCommand):
def handle(self, *args, **options):
tasks = BuildTask.objects.all()
os.system("touch /Users/macbook/Desktop/Start.txt")
if tasks:
os.system("touch /Users/macbook/Desktop/TasksExist.txt")
else:
os.system("touch /Users/macbook/Desktop/TasksNotExist.txt")
os.system("touch /Users/macbook/Desktop/End.txt")
는 :
python manage.py build_task
모든 것이 OK입니다, 내가 Destop에 3 개 개의 파일을 얻을 나는이 튜토리얼 예를 들어 Writing custom django-admin commands
, 내 명령을 사용합니다. 난 그냥 바탕 화면 ("Start.txt")에 1 개 파일을 가져
* * * * * /usr/bin/python /Users/macbook/builder/manage.py build_task
하지만 난 사용 crontab을
. 분명히 스크립트는 작업을 중단합니다.
if tasks:
도와주세요. 뭐가 문제 야?
업데이트 :은/var/메일/맥북 : 왜 "그런 테이블"
File "/Users/macbook/workspace/acodebuilder/home/management/commands/build_apk.py",
line 26, in handle
if tasks:
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 113, in
__nonzero__
iter(self).next()
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 107, in
_result_iter
self._fill_cache()
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 772, in
_fill_cache
self._result_cache.append(self._iter.next())
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 273, in
iterator
for row in compiler.results_iter():
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py", line 680, in
results_iter
for rows in self.execute_sql(MULTI):
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py", line 735, in
execute_sql
cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/util.py", line 34, in
execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py", line 234,
in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: home_buildtask
?