import requests

from django.core.management.base import BaseCommand, CommandError

from us_ignite.apps import importer


class Command(BaseCommand):
    help = 'Import the given JSON file.'

    def handle(self, url, *args, **options):
        response = requests.get(url)
        if not response.status_code == 200:
            raise CommandError('Issue getting the file %s', response.content)
        result = importer.digest_payload(response.json())
        print u'%s apps have been imported.' % len(result)
        print u'Done!'

Implement importer as a management command.
Implement importer as a management command.

Heroku has limitations on the ammount of time that a request
should take.

By using a management command the application can workaround
the time it takes to perform the import.
