from django.core.management.base import BaseCommand, CommandError from django.conf import settings try: import urllib # python 2 except: import urllib.request as urllib # python 3 class Command(BaseCommand): help = 'Initialize saml2 authentication files' def add_arguments(self, parser): pass def handle(self, *args, **options): urllib.urlretrieve(settings.SAML_PROVIDER_METADATA_URL, os.path.join())