Commit caea32a61a46a7f7577ea2035c26ea5111ab335c
1 parent
8e394ec1
Exists in
master
and in
25 other branches
Allow initconfig to execute on first run
Signed-off-by: Sergio Oliveira <sergio@tracy.com.br>
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
colab/utils/runner.py
1 | 1 | |
2 | 2 | import os |
3 | +import sys | |
3 | 4 | |
4 | 5 | from django.core.management import ManagementUtility |
5 | - | |
6 | +from colab.management.commands import initconfig | |
6 | 7 | |
7 | 8 | def execute_from_command_line(argv=None): |
8 | 9 | """ |
9 | 10 | A simple method that runs a ManagementUtility. |
10 | 11 | """ |
11 | 12 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings") |
13 | + from django.conf import settings | |
12 | 14 | |
13 | - utility = ManagementUtility(argv) | |
14 | - utility.execute() | |
15 | + if not hasattr(settings, 'SECRET_KEY') and 'initconfig' in sys.argv: | |
16 | + command = initconfig.Command() | |
17 | + command.handle() | |
18 | + else: | |
19 | + utility = ManagementUtility(argv) | |
20 | + utility.execute() | ... | ... |