Computer scienceBackendDjangoDjango fixes

Custom management commands

Theory

CSV whisperer's command-line dance

Report a typo
Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Fill in the blanks to create a Django management command that reads data from a CSV file. The command should take a file path as an argument and open the file for reading.
Fill in the gaps with the relevant elements
class ():
    help = 'Import data from CSV file into model'
    def (self, ):
        parser.add_argument('file_path', type=str)
    def (self, *args, **options):
        file_path = options['file_path']
        with open(file_path, 'r') as file:
            reader = csv.reader(file)
executeset_argumentsparseradd_argumentsBasicInstructionCommandBaseCommandhandleinterpreterInstruction

Create a free account to access the full topic