TypeError:handle()接受1个位置参数,但给出了2个

update_index.Command().handle(
                    app_label,
                    using=None,
                    remove=indexJob.remove
                    )

import threading
try :
    import queue
except ImportError:
    import Queue as queue
from haystack.management.commands import update_index
from django.conf import settings
import time
from django.db import connection
from django.core import management

TypeError:handle()接受1个位置参数,但给出了2个。我收到了该错误,该函数曾经在django 1.8和python 2中工作,但是现在我移至python 3.6.9和django 2.2 ..并将haystack库更新为2.8.1,我收到了该错误,我看到了在其他地方在stackoverflow上报告了相同的错误..但是对于此特定功能没有帮助。

库中的HANDLE功能就是这种方式

 def handle(self, **options):
    self.verbosity = int(options.get('verbosity', 1))
    self.batchsize = options.get('batchsize', DEFAULT_BATCH_SIZE)
    self.start_date = None
    self.end_date = None
    self.remove = options.get('remove', False)
    self.workers = options.get('workers', 0)
    self.commit = options.get('commit', True)
    self.max_retries = options.get('max_retries', DEFAULT_MAX_RETRIES)

    self.backends = options.get('using')
    if not self.backends:
        self.backends = haystack_connections.connections_info.keys()

    age = options.get('age', DEFAULT_AGE)
    start_date = options.get('start_date')
    end_date = options.get('end_date')

    if self.verbosity > 2:
        LOG.setLevel(logging.DEBUG)
    elif self.verbosity > 1:
        LOG.setLevel(logging.INFO)

    if age is not None:
        self.start_date = now() - timedelta(hours=int(age))

    if start_date is not None:
        from dateutil.parser import parse as dateutil_parse

        try:
            self.start_date = dateutil_parse(start_date)
        except ValueError:
            pass

    if end_date is not None:
        from dateutil.parser import parse as dateutil_parse

        try:
            self.end_date = dateutil_parse(end_date)
        except ValueError:
            pass

    labels = options.get('app_label') or haystack_load_apps()
    for label in labels:
        for using in self.backends:
            try:
                self.update_backend(label, using)
            except:
                LOG.exception("Error updating %s using %s ", label, using)
                raise
评论