call a command in code
from django.core.management import call_command
from elasticsearch.helpers import BulkIndexError
try:
call_command('search_index', *args, *options)
except BulkIndexError as exc:
self.print_error(exc.errors)
from django.core.management import call_command
from elasticsearch.helpers import BulkIndexError
try:
call_command('search_index', *args, *options)
except BulkIndexError as exc:
self.print_error(exc.errors)