2
2
from cms .test_utils .cli import configure
3
3
from cms .test_utils .tmpdir import temp_dir
4
4
import argparse
5
+ from django .utils import autoreload
5
6
import os
6
7
import sys
7
8
@@ -25,22 +26,23 @@ def main():
25
26
}
26
27
}
27
28
)
28
- from django .core .management import call_command
29
- call_command ('syncdb' , interactive = False , migrate_all = new_db )
30
- call_command ('migrate' , interactive = False , fake = new_db )
31
- from django .contrib .auth .models import User
32
- if not User .objects .filter (is_superuser = True ).exists ():
33
- usr = User ()
34
- usr .username = 'admin'
35
-
36
- usr .set_password ('admin' )
37
- usr .is_superuser = True
38
- usr .is_staff = True
39
- usr .is_active = True
40
- usr .save ()
41
- print
42
- print "A admin user (username: admin, password: admin) has been created."
43
- print
29
+ if os .environ .get ("RUN_MAIN" ) != "true" :
30
+ from django .core .management import call_command
31
+ call_command ('syncdb' , interactive = False , migrate_all = new_db )
32
+ call_command ('migrate' , interactive = False , fake = new_db )
33
+ from django .contrib .auth .models import User
34
+ if not User .objects .filter (is_superuser = True ).exists ():
35
+ usr = User ()
36
+ usr .username = 'admin'
37
+
38
+ usr .set_password ('admin' )
39
+ usr .is_superuser = True
40
+ usr .is_staff = True
41
+ usr .is_active = True
42
+ usr .save ()
43
+ print
44
+ print "A admin user (username: admin, password: admin) has been created."
45
+ print
44
46
from django .contrib .staticfiles .management .commands import runserver
45
47
rs = runserver .Command ()
46
48
rs .stdout = sys .stdout
@@ -49,9 +51,7 @@ def main():
49
51
rs ._raw_ipv6 = False
50
52
rs .addr = args .bind
51
53
rs .port = args .port
52
- rs .inner_run (addrport = '%s:%s' % (args .bind , args .port ),
53
- insecure_serving = True )
54
-
54
+ autoreload .main (rs .inner_run , (),{'addrport' :'%s:%s' % (args .bind , args .port ), 'insecure_serving' :True , 'use_threading' :True })
55
55
56
56
if __name__ == '__main__' :
57
57
main ()
0 commit comments