from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand

from ...actions import customers


class Command(BaseCommand):

    help = "Create customer objects for existing users that do not have one"

    def handle(self, *args, **options):
        User = get_user_model()
        for user in User.objects.filter(customer__isnull=True):
            customers.create(user=user)
            self.stdout.write("Created customer for {0}\n".format(user.email))

from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand

from ...actions import customers


class Command(BaseCommand):

    help = "Create customer objects for existing users that do not have one"

    def handle(self, *args, **options):
        User = get_user_model()
        for user in User.objects.filter(customer__isnull=True):
            customers.create(user=user, charge_immediately=False)
            self.stdout.write("Created customer for {0}\n".format(user.email))

Make sure the customer has no plan nor is charged
Make sure the customer has no plan nor is charged

Stripe throws an error because we try to make a charge without having a card. Because we don't have a card for this user yet, it doesn't make sense to charge them immediately.