Skip to content

Commit

Permalink
Fixed createsuperuser init command
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Aymerich Gubern committed Jun 16, 2017
1 parent 35c7265 commit 49c84f1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions orchestra/contrib/accounts/management/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import textwrap

from django.contrib.auth import get_user_model
from django.contrib.auth import get_user_model, base_user
from django.core.exceptions import FieldError
from django.core.management import execute_from_command_line
from django.db import models
Expand All @@ -19,9 +19,14 @@ def create_initial_superuser(**kwargs):
)
from ..models import Account
try:
Account.systemusers.field.related.model.objects.filter(account_id=1).exists()
Account.systemusers.field.model.objects.filter(account_id=1).exists()
except FieldError:
# avoid creating a systemuser when systemuser table is not ready
Account.save = models.Model.save
old_init = base_user.AbstractBaseUser.__init__
def remove_is_staff(*args, **kwargs):
kwargs.pop('is_staff', None)
old_init(*args, **kwargs)
base_user.AbstractBaseUser.__init__ = remove_is_staff
manager = sys.argv[0]
execute_from_command_line(argv=[manager, 'createsuperuser'])

0 comments on commit 49c84f1

Please sign in to comment.