标题真的说了一切,但我现在有这个,但它不起作用:
class Command(BaseCommand):
help = ("Functions related to downloading, parsing, and indexing the "
"content")
def add_arguments(self, parser):
subparsers = parser.add_subparsers()
download_parser = subparsers.add_parser(
'download',
help='Using a local CSV, download the XML data for content. '
'Output is sent to the log.'
)
download_parser.add_argument(
'--start_line',
type=int,
default=0,
help='The line in the file where you wish to start processing.'
)
# Add an argparse parser for parsing the content. Yes, this is
# a bit confusing.
content_parser_parser = subparsers.add_parser(
'parse',
help="Look …Run Code Online (Sandbox Code Playgroud) 我试图以call_command一种非常类似于这个问题的方式使用Django 而没有答案.
我称之为的方式是:
args = []
kwargs = {
'solr_url': 'http://127.0.0.1:8983/solr/collection1',
'type': 'opinions',
'update': True,
'everything': True,
'do_commit': True,
'traceback': True,
}
call_command('cl_update_index', **kwargs)
Run Code Online (Sandbox Code Playgroud)
理论上,根据文档,这应该有效.但它不起作用,它只是不起作用.
这是add_arguments我的Command类的方法:
def add_arguments(self, parser):
parser.add_argument(
'--type',
type=valid_obj_type,
required=True,
help='Because the Solr indexes are loosely bound to the database, '
'commands require that the correct model is provided in this '
'argument. Current choices are "audio" or "opinions".'
)
parser.add_argument(
'--solr-url',
required=True,
type=str,
help='When swapping cores, it …Run Code Online (Sandbox Code Playgroud)