from __future__ import unicode_literals import csv import time from django.apps import apps from django.core import management from django.core.files import File from ...tasks import task_upload_new_document class Command(management.BaseCommand): help = 'Import documents from a CSV file.' def add_arguments(self, parser): parser.add_argument( '--document_type_column', action='store', dest='document_type_column', default=0, help='Column that contains the document type labels. Column ' 'numbers start at 0.', type=int ) parser.add_argument( '--document_path_column', action='store', dest='document_path_column', default=1, help='Column that contains the path to the document files. Column ' 'numbers start at 0.', type=int ) parser.add_argument( '--ignore_errors', action='store_true', dest='ignore_errors', default=False, help='Don\'t stop the import process on common errors like ' 'incorrect file paths.', ) parser.add_argument( '--ignore_rows', action='store', dest='ignore_rows', default='', help='Ignore a set of rows. Row numbers must be separated by commas.' ) parser.add_argument( '--metadata_pairs_column', action='store', dest='metadata_pairs_column', help='Column that contains metadata name and values for the ' 'documents. Use the form: