addist: Allow to be called with an exisitng site.

This commit is contained in:
Julien Palard 2022-10-20 23:23:15 +02:00
parent cb93534a9e
commit 87c8da1a9e
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
1 changed files with 5 additions and 2 deletions

View File

@ -9,5 +9,8 @@ class Command(BaseCommand):
parser.add_argument('domain', type=str)
def handle(self, *args, **options):
site = Site.objects.create(domain=options['domain'], name=options['domain'])
self.stdout.write(self.style.SUCCESS('Created site {}'.format(site)))
site, created = Site.objects.get_or_create(domain=options['domain'], name=options['domain'])
if created:
self.stdout.write(self.style.SUCCESS('Created site {}'.format(site)))
else:
self.stdout.write(self.style.NOTICE('Site {} already exists'.format(site)))