1
執行管理命令我有以下管理命令(website.py)經由URL
from __future__ import absolute_import
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def run_from_argv(self, argv):
self._argv = argv
self.execute()
def handle(self, *args, **options):
from scrapy.cmdline import execute
execute(self._argv[1:])
我想通過URL來執行此命令:/爬行/更新現在/ 的看法是:
from django.core import management
def update_index(request):
management.call_command('website', 'crawl spider')
但它不工作:
Command' object has no attribute '_argv'
你知道嗎?你最終在這裏做了什麼? –