Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Don't create a superuser if already exists

Adam Bogdałf431fab403a2
diff --git a/saleor/product/management/commands/populatedb.py b/saleor/product/management/commands/populatedb.py
index 2db57018be..e8f9a25067 100644
--- a/saleor/product/management/commands/populatedb.py
+++ b/saleor/product/management/commands/populatedb.py
@@ -1,4 +1,5 @@
from django.core.management.base import BaseCommand
+from django.db import IntegrityError
from utils.create_random_data import create_items, create_users, create_orders
@@ -26,6 +27,12 @@ class Command(BaseCommand):
self.stdout.write(msg)
if options['createsuperuser']:
- user = User.objects.create_superuser(
- email='[email protected]', password='admin')
- self.stdout.write('Superuser - %s' % user.email)
+ credentials = {'email': '[email protected]', 'password': 'admin'}
+ try:
+ User.objects.create_superuser(**credentials)
+ except IntegrityError:
+ self.stdout.write(
+ 'Superuser already exists - %(email)s' % credentials)
+ else:
+ self.stdout.write(
+ 'Superuser - %(email)s/%(password)s' % credentials)