forked from briot/geneapro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geneaprove.py
executable file
·34 lines (27 loc) · 1.16 KB
/
geneaprove.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysites.settings")
from django.core.management import execute_from_command_line
from django.conf import settings
# If there is no database, create an empty one
db = settings.DATABASES['default']['NAME']
if not os.path.isfile(db):
print("=======================")
print(f"Creating a new database {db}")
print("=======================")
try:
os.makedirs(os.path.dirname(db))
except OSError:
pass
# Apply all migrations to get the most up-to-date database.
# Migrations are created with:
# ./manage.py makemigrations geneaprove
# (possibly after changing the schema in geneaprove/models/)
execute_from_command_line(["manage.py", "migrate"])
#execute_from_command_line(
# ["manage.py", "migrate", "geneaprove", "zero"])
f = os.path.join('geneaprove/initial_data.json')
execute_from_command_line(["manage.py", "loaddata", f])
execute_from_command_line([sys.argv[0], "runserver", "8000"])