我有以下管理命令(website.py)
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 执行这个命令:/crawl/update-now/ 视图是:
from django.core import management
def update_index(request):
management.call_command('website', 'crawl spider')
但它不起作用:
Command' object has no attribute '_argv'