I have a Django management command, which I pass like this:
python manage.py tenant_command generate_weekly_invoice --start_date 2020-11-30 00:00:00 --end_date 2020-12-06 23:59:00 --schema=schema_name
This doesn't work and I get an error saying that:
argument 1 must be str, not None
I suspect this is to do with the way the actual string of the date 2020-11-30 00:00:00
is being formatted. My management command code is below
generate_weekly_invoice.py
class Command(BaseCommand):
help = 'Generates weekly invoice'
def add_arguments(self, parser):
parser.add_argument('--start_date', nargs='+')
parser.add_argument('--end_date', nargs='+')
def handle(self, *args, **options):
start_str = options.get('--start_date')
end_str = options.get('--end_date')
start_date = datetime.datetime.strptime(start_str, '%Y-%m-%d %H:%M:%S')
end_date = datetime.datetime.strptime(end_str, '%Y-%m-%d %H:%M:%S')
___Logic goes here___
Any help is appreciated
*** Edit:
I should have explained, that I have passed the string in quotation marks but it still returns the same error.